On May 16, 2011, at 9:07 AM, Bing Li wrote: > Dear all, > > I am a new programmer of Cocoa. When learning RunLoop, I felt a little bit > weird. Why should Cocoa provide such a technique? When programming on other > environments, a while-true loop and wait/pulse lock can be used to achieve > the same goal of RunLoop, right?
Well, yes, pre-Carbon Classic Mac OS forced programmers to write their own run loops by polling for events, but why do that when there's code already written for you? > I notice that Cocoa threading can be programmed in the similar way. May I > ignore RunLoop? Only if you're doing some task that will start and exit, and doesn't have to handle events or timers or notifications. Otherwise, you need a run loop. NSApplication and UIApplication will run the main thread's run loop automatically. But if you, for instance, attach a timer to the run loop of another thread, then you need to run that thread's run loop or the timer will not trigger. Nick Zitzmann <http://www.chronosnet.com/> _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com