When to 'release' in Cocoa management?
When to 'release' in Cocoa management?
- Subject: When to 'release' in Cocoa management?
- From: DairyKnight <email@hidden>
- Date: Fri, 21 Aug 2009 15:32:10 +0800
Hi,
In some calls to Cocoa API subroutines we do:
UIView *myView = [[UIView alloc] init];
[window addSubView:myView];
[myView release];
but sometimes you cannot release the temporarily allocated object, e.g. :
UIDatePicler *picker;
... (picker was initialised somewhere)
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?
Thanks.
Regards,
DairyKnight
_______________________________________________
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