NSRunLoop介绍

This class manages input sources for a thread. In Cocoa, input sources may include mouse and keyboard events, as well as NSPortsNSTimers, and NSConnectionsNSRunLoop serves as an interface between an application and the rest of the operating system. When events from the mouse, keyboard, or other peripherals are received in the operating system, they are forwarded to the active application through that application's run-loop. The run-loop monitors all of its input sources continuously for events, and dispatches them to the appropriate object in an application. For more information onNSRunLoop and event handling in Cocoa, see Chapter 3.


Every instance of NSApplication creates and manages its own run-loop. This is the main run-loop of the application. Because this run-loop is created for us, we don't need to use any of the NSRunLoop APIs. However, new threads do not have a run-loop object associated with them. For a thread to participate in event handling and notification from other run-loop sources, create a run-loop for any the thread. If you need to have access to a run-loop object, then you can obtain a pointer to the run-loop of the current thread by invoking the class methodcurrentRunLoop. If you need to start your own run-loop in a thread, you must first create the run-loop using alloc and init, and send a runmessage to the run-loop object.

NSRunLoop objects are based on Core Foundation CFRunLoop objects. The method getCFRunLoop returns an NSRunLoop's underlying Core Foundation run-loop.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值