On Mon, Nov 16, 2009 at 5:18 AM, Austin Ziegler <halosta...@gmail.com> wrote: > Is that true anymore, though? I've been looking at a lot of sample > code lately, and it's very common practice to use "self.foo = ..." in > initializers, even when they're declared nonatomic. I know you said > you don't subscribe to it, but it seems to be an accepted practice > these days.
On the contrary, it is becoming less of an accepted practice. Perhaps the reason you see code like that is because due to a previous compiler bug it was impossible to access synthesized instance variables by any means other than going through their accessors. This has now been fixed; you can use self->foo syntax to get at the instance variable. There are cases where you do, in fact, want to use accessors in your initializer. For example, say you subclass NSObjectController to make some undo-manager-controller thingy (don't ask me what for, this is a hypothetical). You replace its designated initializer with one like -initWithUndoManager:. You might want to call super's -setContent: rather than using the -initWithContent: initializer for whatever reason. > * have two different initializers with different names indicating the > different ownership (e.g., initWithTarget, initWithObserved). You may > have some code duplication here, but you could minimize some of that > with a "- (void)initTimer" method that sets time and calls begin. This is the direction I'd go in. --Kyle Sluder _______________________________________________ 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 arch...@mail-archive.com