NSTimer

作者: 超大玉螺旋连丸 | 来源:发表于2018-06-29 11:14 被阅读0次
  NSTimer *timer = [NSTimer timerWithTimeInterval:1 repeats:YES block:^(NSTimer * _Nonnull timer) {
        
    }];
    [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
    [[NSRunLoop currentRunLoop] run];

timer加入runloop,自动进入倒计时.
[timer setFireDate:[NSDate distantFuture]]; //倒计时暂停
[timer setFireDate:[NSDate distantPast]]; //继续倒计时

[timer invalidate];//倒计时永久停止,但不会释放内存为空.

相关文章

网友评论

      本文标题:NSTimer

      本文链接:https://www.haomeiwen.com/subject/muaoyftx.html