iOS中的定时器

我的技术博客经常被流氓网站恶意爬取转载。请移步原文:http://www.cnblogs.com/hamhog/p/3556805.html,享受整齐的排版、有效的链接、正确的代码缩进、更好的阅读体验。

【初始化】

//参数 timeInterval 为 double 类型,单位为秒;每次到时间时,触发回调函数selector
myTimer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(someFunction) userInfo:nil repeats:YES];
[myTimer setFireDate:[NSDate distantFuture]];

【开始计时】

[myTimer setFireDate:[NSDate date]];

【暂停计时】

[myTimer setFireDate:[NSDate distantFuture]];
原文地址:https://www.cnblogs.com/hamhog/p/3556805.html