Re: Instance variables: access directly vs. getter / setter
Re: Instance variables: access directly vs. getter / setter
- Subject: Re: Instance variables: access directly vs. getter / setter
- From: Matthias Arndt <email@hidden>
- Date: Fri, 9 Oct 2009 13:14:48 +0200
Am 09.10.2009 um 11:30 schrieb Graham Cox:
In init and dealloc, it is usual & recommended to access the ivar
directly - not because self isn't defined (it is), but because at
those times you are usually only concerned with setting the ivar's
initial value (possibly to an object), or releasing it, without side
effects.
Graham,
thanks a lot for clarifying and I stand corrected in concerns of the
"self" definition: Don't know what crossed my mind, how should "init"
return the "self"-pointer without it being defined. So I'll change my
code to use accessors, although
[self setIvar:[self ivar] + 1];
instead of
iVar++;
looks a bit confusing to me. I read that
self.iVar++;
is also supported, but I just don't like the dot-syntax. At least not
yet ...
Thanks again, Matthias
_______________________________________________
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