Re: Why RunLoop?
Re: Why RunLoop?
- Subject: Re: Why RunLoop?
- From: Kyle Sluder <email@hidden>
- Date: Mon, 16 May 2011 10:31:27 -0700
On Mon, May 16, 2011 at 8:07 AM, Bing Li <email@hidden> 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?
Yes, but Cocoa is a framework, not a library. Older APIs (Win32 and
classic Mac OS Carbon) required you to write your own busy loop and
call into the library to get new events to process. Cocoa inverts this
responsibility: your app lives within the framework, not vice versa.
> I notice that Cocoa threading can be programmed in the similar way. May I
> ignore RunLoop?
No. Every thread has at most one runloop, and the main thread must be
processing its runloop in order for your app to function. The
framework requires it.
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden