Re: When to 'release' in Cocoa management?
Re: When to 'release' in Cocoa management?
- Subject: Re: When to 'release' in Cocoa management?
- From: Graham Cox <email@hidden>
- Date: Fri, 21 Aug 2009 17:38:21 +1000
On 21/08/2009, at 5:32 PM, DairyKnight wrote:
NSDate *date = [[NSDate alloc] init];
[picker setDate:date];
[date release]; // Opps! immediate release of 'date' causes program
crash.
So is there a rule of thumb, like when should we release immediately
after
passing the object to some Cocoa API calls?
This should work OK, so if it's crashing, you have a bug elsewhere.
Once you are no longer interested in an object, you are free to
release it. Another object that needs to keep it will retain it.
--Graham
_______________________________________________
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