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 ...
随机推荐
- Swift开发小技巧--扫描二维码,二维码的描边与锁定,设置扫描范围,二维码的生成(高清,无码,你懂得!)
二维码的扫描,二维码的锁定与描边,二维码的扫描范围,二维码的生成(高清,无码,你懂得!),识别相册中的二维码 扫描二维码用到的三个重要对象的关系,如图: 1.懒加载各种类 // MARK: - 懒加载 ...
- 【POJ 2503】Babelfish(字符串)
题 给定字典,再询问. 字典与询问之间有一个空行. cin.peek()是一个指针指向当前字符. #include<iostream> #include<string> #in ...
- 用 phylomatic 软件生成的进化树
用 phylomatic 软件生成的进化树 Phylomatic是在线软件,可以利用植物名录,按照APGIII的被子植物科的拓扑结构,生成进化树. 参考 张金龙博士 工作目录 setwd(" ...
- oracle调用java方法的例子(下面所有代码都是在sql/plus中写)
在Oracle中调用Java程序,注意:java方法必须是static类型的,如果想在JAVA中使用system.out/err输出log. 需要在oracle 中执行"call dbms_ ...
- Leetcode First Bad Version
You are a product manager and currently leading a team to develop a new product. Unfortunately, the ...
- POJ1061 青蛙的约会
Description 两 只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面.它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止.可是它 们出发之前忘记了一件很重要 ...
- 利用iconv进行文件编码批量原地转换
将当前目录及其所有子目录中的以 java 为后缀的文件,从 GB18030 转换为 UTF-8: find . -name "*.java" -exec sh -c " ...
- phpize报cannot find autoconf
突然想往php种增加个模块,可是又不想重新编译php,因为真的比较费时间. phpize就可以解决这个问题. 遇到的问题: Configuring for: PHP Api Version: Zend ...
- Centos下 为Firefox安装Flash插件
方法一: 直接到官网去下载RPM格式的安装包,下载好后直接 用 rpm -ivh XXXX.rpm 来安装即可. 方法二: 到官网下载tar.gz格式的,自己配置安装: #wget http://fp ...
- CF 363B One Bomb(枚举)
题目链接: 传送门 One Bomb time limit per test:1 second memory limit per test:256 megabytes Description ...