On Jun 25, 2012, at 12:48 AM, fly2never wrote: > Then I call Monkey *m1 = [[Monkey alloc] init]; > and I call [m1.foodLists addObject:foo]; , it crashes.
That won’t crash, because all instance variables are automatically initialized to nil. Sending the addObject: message to a nil object won’t crash — but neither will it do what you want. Instead, it won’t do anything, and your ‘foo’ object won’t get added — probably not what you want. Also, I wouldn’t give the user direct access to your internal NSMutableArray and let them monkey with it directly. Instead, implement a to-many property backed by the NSMutableArray, with which the users of the class can interact instead of directly with the array. Charles _______________________________________________ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com