On Wed, Nov 19, 2008 at 6:32 PM, Carmen Cerino Jr. <[EMAIL PROTECTED]> wrote: > I guess I should also have included what spawned this question in the > first place. I have read in a handful of places that you can > guarantee, in the example case, that blah will exist until the end of > function, and that sometime after the end of the scope of the function > blah will be released. So if you don't know when it will be released, > is there a possibility of it being released before control gets back > to the caller so it can retain it?
The documentation used to be ambiguous on this point, but with the addition of garbage collection has been rewritten to be more explicit: http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/chapter_3_section_5.html "...the Application Kit automatically sets up an autorelease pool scoped to the application's event cycle." So when your app finishes processing a message from the WindowServer, it flushes the autorelease pool. When this happens is sort of indeterminate, but can't happen in between the return statement and the next evaluation in the caller, because there's no opportunity for other code to execute that will run the runloop (which is where the event cycle lives). This is all operating under a single-threaded assumption. If you start multi-threading your app, YMMV. --Kyle Sluder _______________________________________________ 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 [EMAIL PROTECTED]