定时器注意

1.注意要将定时器加入RunLoop中去(避免其他事件暂停了定时器事件)

        _timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerCountDown) userInfo:nil repeats:YES];
        [[NSRunLoop mainRunLoop] addTimer:_timer forMode:UITrackingRunLoopMode];

2.在界面小时,记得销毁定时器,且置为nil

    [_timer invalidate];
    _timer = nil;
此文章为个人笔记,方便自己以及有需要的朋友查看,转载请注明出处!
原文地址:https://www.cnblogs.com/shpyoucan/p/5481302.html