iOS面试题: Runloop的基本使用

引言

  • RunLoop:An event-processing loop, during which events are received and dispatched to appropriate handlers.

  • 作用

1、决定程序在何时应该处理哪些事件:app会有很多事件,Runloop会有一定的机制来管理事件的处理时机
2、调用解耦(Message Queue)

I 使用例子

1.1 往运行循环添加特定事件的目标和动作

将监听方法click注册到“运行循环”,当触发ControlEvent事件时,由“运行循环”通知Target(ViewController) 执行action(@selector)

 

猜你喜欢

转载自blog.csdn.net/u011018979/article/details/123745284