Re: Autoreleased Data In Cocoa
Re: Autoreleased Data In Cocoa
- Subject: Re: Autoreleased Data In Cocoa
- From: Nick Zitzmann <email@hidden>
- Date: Tue, 31 May 2011 09:44:59 -0600
On May 31, 2011, at 9:32 AM, Bing Li wrote:
> But I still have a question. If the autoreleased data will keep alive until the pool is drained, what if the data is autoreleased in a Cocoa auto-created pool? It will keep alive unless the process is shutdown?
No. The framework makes and drains pools as your application goes about its business. Just stick to the rules and don't worry about pools that are outside of your control.
> Thanks!
> Bing
>
> - (NSString *) receiveMessage
> {
> NSMutableString *receivedString;
I would recommend initializing this to nil. Although it's highly unlikely, if a C++ or ObjC exception is thrown prior to receivedString being set, then your @finally method is going to crash sending an autorelease message to an uninitialized pointer.
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
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