首页 > 学院 > 开发设计 > 正文

iOS中的定时器-NSTimer使用方法

2019-11-14 20:41:18
字体:
来源:转载
供稿:网友

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

【初始化】

//参数 timeInterval 为 double 类型,单位为秒;每次到时间时,触发回调函数selectormyTimer = [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]];

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表