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 ...
随机推荐
- 线性回归&&code
# -*- coding: utf-8 -*- import numpy as np import matplotlib.pyplot as plt from certifi import __mai ...
- GIF/PNG/JPG和WEBP/base64/apng图片优点和缺点整理
GIF/PNG/JPG/WEBP/APNG都是属于位图(位图 ,务必区别于矢量图): GIF/PNG和JPG这三种格式的图片被广泛应用在现今的互联网中,gif曾在过去互联网初期慢速的情况下几乎是做到了 ...
- 强连通 HDU 3861
t个样例 n个点m条边 分成一些区 2个点互相能到达必须分在一个区 一个区中任何2个点可以u->v 或者v->u 任何点都要有自己的区 求最小的区的数目 强联通缩点 成新图 二分匹配 求最 ...
- Mybatis + SpringMVC + Maven实现分页查询
使用Mybatis + Maven + SpringMVC 运行时,突然被需要分页查询的功能给难住了 这里推荐采用的插件是PageHelper这个插件,使用起来十分方便.该插件支持以下数据库: Ora ...
- 自定义多列排序:C++/Java实现
前言: 有些时候,我们在编程中会遇到多列排序的需求.假如在execle,这事儿就太easy了.不过没办法,现在就需要你用Java或者C++实现这样一个功能! 比如将下表无序的数据通过重排之后按照以下规 ...
- C/C++中数组转换成指针的情况
数组转换成指针:在大多数用到数组的表达式中,数组自动转换成指向数组首元素的指针.比如: int ia[10]; int *p = ia; //ia转换成指向数组首元素的指针 以下情况上述转换不会发生: ...
- Leetcode Wiggle Sort II
Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3]... ...
- PHP Multipart/form-data remote dos Vulnerability
catalog . Description . Analysis 1. Description PHP is vulnerable to a remote denial of service, cau ...
- 添加一个功能Action
1,只用一个handler类,所有都事件的处理器都在一个handler类 handler要创建以Action为名称的方法 event要单独分开,继承KDEvent package com.kingde ...
- linux 内核 RCU机制详解
RCU(Read-Copy Update)是数据同步的一种方式,在当前的Linux内核中发挥着重要的作用.RCU主要针对的数据对象是链表,目的是提高遍历读取数据的效率,为了达到目的使用RCU机制读取数 ...