On Thu, Jun 12, 2008 at 2:00 AM, Bob Warwick <[EMAIL PROTECTED]> wrote: > Calling the NSMutableArray convenience method array will return an > autoreleased object. You should do this instead: > > - (id) init > { > [super init]; > myNotes = [[NSMutableArray alloc] init]; > return self; > }
Actually, it should really be like this (I've been pedantically explicit): - (id)init { self = [super init]; if(self != nil) { myNotes = [[NSMutableArray alloc] init]; } return self; } Note that -init is NOT required to return the same object that "self" refers to. Therefore it is always required that you re-assign self in your overridden initializer if you need to access it, and you must return that modified self*. --Kyle Sluder * Please note that this is the common case. If you're implementing the singleton pattern, for example, you would override -init differently. And there are other cases like class clusters where you will instead be returning different objects from -init that super's implementation returns. But these are Very Advanced Topics(TM). _______________________________________________ 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]