iOS registration, retrieve password when used to obtain the verification code

Source: Internet
Author: User
<span id="Label3"></p><p><p></p></p><pre><span style="color: #0000ff;"><span style="color: #0000ff;">#import</span></span> <span style="color: #800000;"><span style="color: #800000;">"</span></span><span style="color: #800000;"><span style="color: #800000;">ViewController.h</span></span><span style="color: #800000;"><span style="color: #800000;">"</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">#import</span></span> <span style="color: #800000;"><span style="color: #800000;">"</span></span><span style="color: #800000;"><span style="color: #800000;">nstimer+blockskit.h</span></span><span style="color: #800000;"><span style="color: #800000;">"</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">@interface</span></span><span style="color: #000000;"><span style="color: #000000;">Viewcontroller () {nstimer</span></span>*vcodebuttontimer1, *<span style="color: #000000;"><span style="color: #000000;">vCodeButtonTimer2;} @property (weak, nonatomic) iboutlet UIButton</span></span>*<span style="color: #000000;"><span style="color: #000000;">button;</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">@end</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">@implementation</span></span><span style="color: #000000;"><span style="color: #000000;">Viewcontroller</span></span>-(ibaction) Action: (<span style="color: #0000ff;"><span style="color: #0000ff;">ID</span></span><span style="color: #000000;"><span style="color: #000000;">) Sender {__block</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">int</span></span>Time =<span style="color: #800080;"><span style="color: #800080;">8</span></span><span style="color: #000000;"><span style="color: #000000;">; VCodeButtonTimer1</span></span>= [nstimer Bk_scheduledtimerwithtimeinterval:<span style="color: #800080;"><span style="color: #800080;">1</span></span>block:^ (nstimer *<span style="color: #000000;"><span style="color: #000000;">Timer) {[self.button settitle:[nsstring stringwithformat:</span></span><span style="color: #800000;"><span style="color: #800000;">@"</span></span><span style="color: #800000;"><span style="color: #800000;">%ds after re-acquisition</span></span><span style="color: #800000;"><span style="color: #800000;">"</span></span>, time--<span style="color: #000000;"><span style="color: #000000;">] forstate:uicontrolstatedisabled]; [self.button setenabled:no]; } repeats:yes]; [vCodeButtonTimer1 fire]; VCodeButtonTimer2</span></span>= [nstimer Bk_scheduledtimerwithtimeinterval:<span style="color: #800080;"><span style="color: #800080;">7</span></span>block:^ (nstimer *<span style="color: #000000;"><span style="color: #000000;">Timer) {[vCodeButtonTimer1 invalidate]; VCodeButtonTimer1</span></span>=<span style="color: #000000;"><span style="color: #000000;">nil; [self.button setenabled:yes]; } repeats:no];}</span></span></pre><p class="p1"><p class="p1"><span class="s1">-(<span class="s2">void<span class="s1">) Dealloc</span> </span></span></p></p><pre><pre></pre></pre><p class="p1"><p class="p1"><span class="s1">{</span></p></p><pre><pre></pre></pre><p class="p2"><p class="p2"><span class="s3">[<span class="s1">vCodeButtonTimer2<span class="s3"> <span class="s4">invalidate<span class="s3">];</span> </span> </span> </span></span></p></p><pre><pre></pre></pre><p class="p2"><p class="p2"><span class="s3">[<span class="s1">vCodeButtonTimer1<span class="s3"> <span class="s4">invalidate<span class="s3">];</span> </span> </span> </span></span></p></p><pre><pre></pre></pre><p class="p1"><p class="p1"><span class="s1">}</span></p></p><pre><pre><span style="color: #0000ff;">@end</span></pre></pre><p><p></p></p><p><p>The Blockit file used</p></p><pre><span style="color: #0000ff;"><span style="color: #0000ff;">#import</span></span><Foundation/Foundation.h><span style="color: #008000;"><span style="color: #008000;">/*</span></span><span style="color: #008000;"><span style="color: #008000;">* Simple category on Nstimer to give it blocks Capability. Created by [Jiva devoe] (</span></span><span style="color: #008000; text-decoration: underline;"><span style="color: #008000; text-decoration: underline;">Https://github.com/jivadevoe</span></span><span style="color: #008000;"><span style="color: #008000;">) as ' Nstimer-blocks '.</span></span><span style="color: #008000;"><span style="color: #008000;">*/</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">@interface</span></span><span style="color: #000000;"><span style="color: #000000;">Nstimer (blockskit)</span></span><span style="color: #008000;"><span style="color: #008000;">/*</span></span><span style="color: #008000;"><span style="color: #008000;">* 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, the Nstimer fires. @param inrepeats If YES, the timer would repeatedly reschedule itself until Invalidated. If NO, The timer is invalidated after it fires. @return A new Nstimer object, configured according to the specified Parameters. </span></span><span style="color: #008000;"><span style="color: #008000;">*/</span></span>+ (nstimer *) bk_scheduledtimerwithtimeinterval: (nstimeinterval) intimeinterval block: (<span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span>(^) (nstimer *<span style="color: #000000;"><span style="color: #000000;">Timer)) Inblock repeats: (BOOL) inrepeats;</span></span><span style="color: #008000;"><span style="color: #008000;">/*</span></span><span style="color: #008000;"><span style="color: #008000;">* 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 has elapsed, the timer fires the BLOCK. If the timer is configured to repeat, there are no need to subsequently re-add the Timer. @param intimeinterval The number of seconds between firings of the Timer. @param inblock The block, the Nstimer fires. @param inrepeats If YES, the timer would repeatedly reschedule itself until Invalidated. If NO, The timer is invalidated after it fires. @return A new Nstimer object, configured according to the specified Parameters. </span></span><span style="color: #008000;"><span style="color: #008000;">*/</span></span>+ (nstimer *) bk_timerwithtimeinterval: (nstimeinterval) intimeinterval block: (<span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span>(^) (nstimer *<span style="color: #000000;"><span style="color: #000000;">Timer)) Inblock repeats: (BOOL) inrepeats;</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">@end</span></span></pre><pre><span style="color: #0000ff;"><span style="color: #0000ff;">#import</span></span> <span style="color: #800000;"><span style="color: #800000;">"</span></span><span style="color: #800000;"><span style="color: #800000;">nstimer+blockskit.h</span></span><span style="color: #800000;"><span style="color: #800000;">"</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">@interface</span></span><span style="color: #000000;"><span style="color: #000000;">Nstimer (blockskitprivate)</span></span>+ (<span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span>) Bk_executeblockfromtimer: (nstimer *<span style="color: #000000;"><span style="color: #000000;">) atimer;</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">@end</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">@implementation</span></span><span style="color: #000000;"><span style="color: #000000;">Nstimer (blockskit)</span></span>+ (<span style="color: #0000ff;"><span style="color: #0000ff;">ID</span></span>) bk_scheduledtimerwithtimeinterval: (nstimeinterval) Intimeinterval block: (<span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span>(^) (nstimer *<span style="color: #000000;"><span style="color: #000000;">Timer)) Block Repeats: (BOOL) Inrepeats{nsparameterassert (block</span></span>!=<span style="color: #000000;"><span style="color: #000000;">nil); </span></span><span style="color: #0000ff;"><span style="color: #0000ff;">return</span></span><span style="color: #000000;"><span style="color: #000000;">[self scheduledtimerwithtimeinterval:intimeinterval target:self selector: @selector (bk_executeblockfromtimer:) Userinfo:[block copy] repeats:inrepeats];}</span></span>+ (<span style="color: #0000ff;"><span style="color: #0000ff;">ID</span></span>) bk_timerwithtimeinterval: (nstimeinterval) Intimeinterval block: (<span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span>(^) (nstimer *<span style="color: #000000;"><span style="color: #000000;">Timer)) Block Repeats: (BOOL) Inrepeats{nsparameterassert (block</span></span>!=<span style="color: #000000;"><span style="color: #000000;">nil); </span></span><span style="color: #0000ff;"><span style="color: #0000ff;">return</span></span><span style="color: #000000;"><span style="color: #000000;">[self timerwithtimeinterval:intimeinterval target:self selector: @selector (bk_executeblockfromtimer:) userInfo: [block copy] repeats:inrepeats];}</span></span>+ (<span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span>) Bk_executeblockfromtimer: (nstimer *<span style="color: #000000;"><span style="color: #000000;">) Atimer {</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span>(^block) (nstimer *) =<span style="color: #000000;"><span style="color: #000000;">[atimer userInfo]; </span></span><span style="color: #0000ff;"><span style="color: #0000ff;">if</span></span><span style="color: #000000;"><span style="color: #000000;">(block) block (atimer);}</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">@end</span></span></pre><p><p></p></p><p><p>iOS registration, retrieve password when used to obtain the verification code</p></p></span>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.