• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Why RunLoop?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Why RunLoop? (From: Bing Li <email@hidden>)

  • Prev by Date: Re: NSPostWhenIdle not doing its job?
  • Next by Date: Re: NSLayoutManager didCompleteLayout callback & NSFormFeedCharacter
  • Previous by thread: Re: Why RunLoop?
  • Next by thread: Re: Why RunLoop?
  • Index(es):
    • Date
    • Thread