This class manages input sources for a thread. In Cocoa,input sources may include mouse and keyboard events,as well as NSPorts, NSTimers,and NSConnections. NSRunLoop 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 @R_669_4045@ion 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.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。