ios - nsrunloop究竟如何使用,怎么样才能在一个线程中使用nsrunloop进行死循环进行事件监听与处理?
阿神
阿神 2017-04-18 09:39:25
0
1
391

NSRunLoop是苹果的平台下的消息处理机制,我们都知道消息处理就是一个永无至今的循环,进行处理I/O,看了很多文章的介绍、官方文档甚至看了有些人的源码(CFRunLoopRef)分析,有如下几个问题希望各路高手能够进行解答。
1.NSRunLoop究竟是一个什么东西?里面是一个死循环?有消息的监听和收发?
2.NSRunLoop究竟是怎么具体唤醒和休眠线程的?
3.NSRunLoop何如接受我们自定义的时间对其所在的线程进行休眠和唤醒?
4.NSTimer和NSRunLoop究竟有什么关系,如果一个repeat的NSTimer和NSRunLoop的循环有什么关系?
5.我们能通过使用NSRunLoop或者是CFRunLoopRef自己构建事件循环吗?简单的那种,不是像App内那种监控各种复杂事件的,简单的实现特定的输入和输出,使得线程得以休眠和唤醒。
希望各路高手能够有兴趣回答一下,不胜感激!

阿神
阿神

闭关修行中......

reply all(1)
伊谢尔伦

Regarding RunLoop and Runtime, they are actually not used much in general projects. Many people (me too) have only a little knowledge of them. I personally think they are only used during interviews to show off.
I can answer most of your questions. I thought I’d give you a link. Just read it before pretending, http://www.cnblogs.com/ioshe/...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template