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 ...
随机推荐
- 关于二叉排序树 BST
#include<stdio.h> #include<stdlib.h> typedef struct node { double w; struct node *l,*r; ...
- java-Date、String、Calendar转化
1.Calendar 转化 String //获取当前时间的具体情况,如年,月,日,week,date,分,秒等 Calendar calendat = Calendar.getInstance(); ...
- 使用iframe 或frameset框架退出不成功
iframe .frameset框架有时登录界面加载在框架当中,但我们想直接到登录界面,这时我们可以使用js来实现.if(window!=top) { top.location.href=locati ...
- 自定义不等高cell—storyBoard或xib自定义不等高cell
1.iOS8之后利用storyBoard或者xib自定义不等高cell: 对比自定义等高cell,需要几个额外的步骤(iOS8开始才支持) 添加子控件和contentView(cell的content ...
- Leetcode #28. Implement strStr()
Brute Force算法,时间复杂度 O(mn) def strStr(haystack, needle): m = len(haystack) n = len(needle) if n == 0: ...
- 【BZOJ-3555】企鹅QQ 字符串Hash
3555: [Ctsc2014]企鹅QQ Time Limit: 20 Sec Memory Limit: 256 MBSubmit: 1545 Solved: 593[Submit][Statu ...
- NuGet包引用依赖问题
如A包需要引用B包,然后在项目中安装A包时,自动把B包也装上. 在nuget命令行打包的时候,如果是指定项目的csproj文件进行打包的,都只能打包当前项目的dll,那么如果使用了第三方的dll而没有 ...
- JSP_通过表格显示数据库的信息
在本篇文章中,小编将介绍在jsp页面中通过表格显示数据库的实现:下面我们以“新闻发布系统”中显示一级标题的信息为例进行讲述,在新闻发布系统中存在一二级标题,在后台可以对标题进行管理,可查询标题等信息 ...
- xml解析模块
XML XML是可扩展标记语言的缩写,是实现不同语言或程序之间进行数据交换的协议,主要可以对key添加属性. 页面做展示(字符类型的一个xml格式数据)\做配置文件(内部xml格式的数据).,每一个节 ...
- LaTeX test
\begin{equation} x^2+1=2 \end{equation} \begin{equation} x^2+y=3 \end{equation} $\dfrac{2\pi}{N}$