码迷,mamicode.com
首页 > 其他好文 > 详细

dispatch_source_t

时间:2015-11-24 21:12:44      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:

dispatch_source_t的作用:监听某些事件,当这些事件发生的时候,他就会把这些事件的回调的block提交到某些队列上变执行。

@abstract

 * Creates a new dispatch source to monitor low-level system objects and auto-

 * matically submit a handler block to a dispatch queue in response to events. 

 

所以使用 dispatch_source_t分为三步:

1.创建dispatch_source_create(param1,param2,param3,param4)

参数解释:

    param1:监听的事件类型,比如:DISPATCH_SOURCE_TYPE_TIMER,DISPATCH_SOURCE_TYPE_SIGNAL等

    parma4:当事件发生时,指定回调block放置的队列

2.设置dipatch_source_t的属性

比如:dispatch_set_timer(param1,param2,param3,param4)

参数解释:

    param1: dipatch_source_t变量  

    param3:时间间隔 

3.设置dipatch_source_t的回调block

dispatch_source_set_event_handler(param1,param2)

   param1: dipatch_source_t变量

   param2:回调的block

4.启动 dipatch_source_t

   resume()

5.取消

   cancel() 

 

 

dispatch_source_t

标签:

原文地址:http://www.cnblogs.com/Sunnyheart/p/4992828.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!