GCD定时器
来源:互联网 发布:nba骑士数据 编辑:程序博客网 时间:2024/05/22 18:22
// 比NSTimer更精准,不受RunLoop的Model影响int count = 0;- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ // 获得队列 dispatch_queue_t queue = dispatch_get_global_queue(0, 0); // 1 创建一个定时器 self.timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);// dispatch_time_t start = dispatch_time(DISPATCH_TIME_NOW, 3.0 * NSEC_PER_SEC);// dispatch_time_t interval = 2.0 * NSEC_PER_SEC; dispatch_source_set_timer(self.timer, DISPATCH_TIME_NOW, 2.0 * NSEC_PER_SEC, 0.0 * NSEC_PER_SEC); dispatch_source_set_event_handler(self.timer, ^{ NSLog(@"------%@", [NSThread currentThread]); count++; if (count == 4) { dispatch_cancel(self.timer); self.timer = nil; } }); dispatch_resume(self.timer);}
0 0
- GCD定时器
- GCD定时器
- GCD 定时器
- GCD 定时器
- GCD定时器
- GCD定时器
- GCD定时器
- GCD定时器
- GCD 定时器
- GCD中的定时器
- iOS GCD 进程定时器
- GCD的定时器
- GCD定时器的实现
- iOS GCD 定时器
- iOS GCD定时器
- GCD定时器不起作用原因
- GCD创建一个定时器
- ios GCD 定时器
- js 引号问题
- iOS中的一些缓存处理
- VMware 11、12安装Mac OS X 10.10 及安装Mac Vmware Tools.
- #ifdef,#else,#endif,#if预处理详解
- 明-海瑞 《治安疏》
- GCD定时器
- 求HashMap的hashCode
- 怎么把PDF文件中的图片全部提取出来
- 你真的会使用XMLHttpRequest吗?
- MQTT客户端移植到STM32
- zookeeper curator 源码试读
- sql中date数据处理
- iOS开发中的一些缓存机制
- Android 第三方QQ、微信、微博登录分享