iOS注册,找回密码时用到的获取验证码

#import "ViewController.h"
#import "NSTimer+BlocksKit.h" @interface ViewController ()
{
NSTimer *vCodeButtonTimer1, *vCodeButtonTimer2; }
@property (weak, nonatomic) IBOutlet UIButton *button;
@end @implementation ViewController
- (IBAction)action:(id)sender { __block int time = ;
vCodeButtonTimer1 = [NSTimer bk_scheduledTimerWithTimeInterval: block:^(NSTimer *timer) {
[self.button setTitle:[NSString stringWithFormat:@"%ds后重新获取", time --] forState:UIControlStateDisabled];
[self.button setEnabled:NO];
} repeats:YES]; [vCodeButtonTimer1 fire]; vCodeButtonTimer2 = [NSTimer bk_scheduledTimerWithTimeInterval: block:^(NSTimer *timer) {
[vCodeButtonTimer1 invalidate];
vCodeButtonTimer1 = nil;
[self.button setEnabled:YES];
} repeats:NO];
}
- (void)dealloc
{
[vCodeButtonTimer2 invalidate];
[vCodeButtonTimer1 invalidate];
}
@end
用到的blockit文件
#import <Foundation/Foundation.h> /** Simple category on NSTimer to give it blocks capability. Created by [Jiva DeVoe](https://github.com/jivadevoe) as `NSTimer-Blocks`.
*/
@interface NSTimer (BlocksKit) /** Creates and returns a block-based NSTimer object and schedules it on the current run loop. @param inTimeInterval The number of seconds between firings of the timer.
@param inBlock The block that the NSTimer fires.
@param inRepeats If YES, the timer will repeatedly reschedule itself until invalidated. If NO, the timer will be invalidated after it fires.
@return A new NSTimer object, configured according to the specified parameters.
*/
+ (NSTimer *)bk_scheduledTimerWithTimeInterval:(NSTimeInterval)inTimeInterval block:(void (^)(NSTimer *timer))inBlock repeats:(BOOL)inRepeats; /** Creates and returns a block-based NSTimer initialized with the specified block. You must add the new timer to a run loop, using `-addTimer:forMode:`. Then,
after seconds seconds have elapsed, the timer fires the block. If the timer
is configured to repeat, there is no need to subsequently re-add the timer. @param inTimeInterval The number of seconds between firings of the timer.
@param inBlock The block that the NSTimer fires.
@param inRepeats If YES, the timer will repeatedly reschedule itself until invalidated. If NO, the timer will be invalidated after it fires.
@return A new NSTimer object, configured according to the specified parameters.
*/
+ (NSTimer *)bk_timerWithTimeInterval:(NSTimeInterval)inTimeInterval block:(void (^)(NSTimer *timer))inBlock repeats:(BOOL)inRepeats; @end
#import "NSTimer+BlocksKit.h" @interface NSTimer (BlocksKitPrivate) + (void)bk_executeBlockFromTimer:(NSTimer *)aTimer; @end @implementation NSTimer (BlocksKit) + (id)bk_scheduledTimerWithTimeInterval:(NSTimeInterval)inTimeInterval block:(void (^)(NSTimer *timer))block repeats:(BOOL)inRepeats
{
NSParameterAssert(block != nil);
return [self scheduledTimerWithTimeInterval:inTimeInterval target:self selector:@selector(bk_executeBlockFromTimer:) userInfo:[block copy] repeats:inRepeats];
} + (id)bk_timerWithTimeInterval:(NSTimeInterval)inTimeInterval block:(void (^)(NSTimer *timer))block repeats:(BOOL)inRepeats
{
NSParameterAssert(block != nil);
return [self timerWithTimeInterval:inTimeInterval target:self selector:@selector(bk_executeBlockFromTimer:) userInfo:[block copy] repeats:inRepeats];
} + (void)bk_executeBlockFromTimer:(NSTimer *)aTimer {
void (^block)(NSTimer *) = [aTimer userInfo];
if (block) block(aTimer);
} @end
iOS注册,找回密码时用到的获取验证码的更多相关文章
- 修复 WordPress 通过邮箱 找回密码时的链接无效&新用户注册时提示的链接无效
感谢大佬:https://blog.csdn.net/xiaobinqt/article/details/83055058 感谢大佬:https://www.wpdaxue.com/lost-pass ...
- (进阶篇)PHP+Mysql+jQuery找回密码
通常所说的密码找回功能不是真的能把忘记的密码找回,因为我们的密码是加密保存的,一般开发者会在验证用户信息后通过程序生成一个新密码或者生成一个特定的链接并发送邮件到用户邮箱,用户从邮箱链接到网站的重置密 ...
- ThinkPHP 3.2 用户注册邮箱验证帐号找回密码
一.前言 当然现在有的网站也有手机短信的方式找回密码,原理就是通过发送验证码来验明正身,和发送邮件验证一样,最终还是要通过重置密码来完成找回密码的流程. 本文将使用PHP+Mysql+jQuery来实 ...
- PHP+Mysql+jQuery找回密码
通常所说的密码找回功能不是真的能把忘记的密码找回,因为我们的密码是加密保存的,一般开发者会在验证用户信息后通过程序生成一个新密码或者生成一个特定的链接并发送邮件到用户邮箱,用户从邮箱链接到网站的重置密 ...
- Django 邮箱找回密码!!!!!!!!!!!!!!!!
1.大概流程. @首先在完善登陆页面,增加忘记密码的链接. @为了账户安全,需要对操作者进行验证,向邮箱发随机数验证! @在重置验证码页面,验证验证码是否匹配(验证成功跳转至更改密码也页面). @ 重 ...
- iOS 注册密码加密 添加了时间戳 遇到的问题...
今天项目 遇到一个事故,我本想用 一个形容这个事故的adj 算了 既然 叫事故 已经能表达我们处于的一种状态, 是这样的: 有小部分用户反应 app无法注册 总提示密码错误的情况 实际 该步骤 已经 ...
- WordPress 使用 Pie-Register 添加前台注册、登录、找回密码和编辑个人资料功能
转自:http://www.wpdaxue.com/front-end-publishing.html Pie-Register 是一个功能比较完善的 WordPress 才能,使用它可以很方便添加和 ...
- Java实现邮箱找回密码
通过邮件找回密码功能的实现 1.最近开发一个系统,有个需求就是,忘记密码后通过邮箱找回.现在的系统在注册的时候都会强制输入邮箱,其一目的就是 通过邮件绑定找回,可以进行密码找回.通过java发送邮件的 ...
- javaWeb实现使用邮箱邮件找回密码功能
JSP+Jmail+JavaBean 发邮件(转)2010-08-23 18:052007年04月14日 14:32/* * SendMail.java * * Created on 2007年3月3 ...
随机推荐
- python日常-list and dict
什么是list: list 觉得算是python日常编程中用的最多的python自带的数据结构了.但是python重的list跟其他语言中的并不相同. 少年..不知道你听说过python中的appen ...
- dede使用方法----调用列表页的分页功能
分页的标签:<div class="dede_pages"> <ul class="pagelist"> {dede:pagelist ...
- C# 不支持关键字: “.;database”。
解决方案分析:这个一定是链接字符串有问题,核对web.config 和程序的字符串是否有误
- adb错误解决
1.adb是什么?ADB全称Android Debug Bridge, 是android sdk里的一个工具,用这个工具可以直接操作管理android模拟器或者真实的andriod设备. 2.调试安卓 ...
- [日常训练]常州集训day7
T1 Description 给定一个序列,初始为空.依次将$1-n$插入序列,其中$i$插到当前第$a_i$个数的右边($a_i=0$表示插到序列最左边).求最终序列. Input 第一行一个整数$ ...
- 配置服务器有错/usr/libexec/gconf-sanity-check-2的退出状态为256
问题描述: CentOS启动的时候报如下错误:“配置服务器有错/usr/libexec/gconf-sanity-check-2的退出状态为256” 问题原因: 在装hadoop的时候误删了/tmp文 ...
- 【BZOJ-1369】Gem 树形DP
1369: [Baltic2003]Gem Time Limit: 2 Sec Memory Limit: 64 MBSubmit: 282 Solved: 180[Submit][Status] ...
- Java Attach API
catalog . instrucment与Attach API . BTrace: VM Attach的两种方式 . Sun JVM Attach API 1. instrucment与Attach ...
- BackGroundWorker控件的使用注意
该控件有三个事件: DoWork .ProgressChanged 和 RunWorkerCompleted 在程序中调用RunWorkerAsync方法则会启动DoWork事件的事件处理,当在事件处 ...
- [iOS 基于CoreBluetooth的蓝牙4.0通讯]
一.首先大致介绍下蓝牙4.0的模式,中心和周边: 一般情况下,iPhone作为中心,接收来自周边传感器(比如手环等)采集的数据. 二.那整一个数据通讯的协议是怎样的呢? 为什么要一层层搞这么复杂呢?据 ...