Re: Properties vs Instance Variables
Re: Properties vs Instance Variables
- Subject: Re: Properties vs Instance Variables
- From: Joanna Carter <email@hidden>
- Date: Wed, 27 Apr 2011 17:59:33 +0100
Le 27 avr. 2011 à 17:39, David Duncan a écrit :
> @property(...) id foo;
> @synthesize foo = _foo;
>
> Then the following holds:
> _foo and self->_foo are equivalent means of direct ivar access.
> self.foo = bar and [self setFoo:bar] are equivalent means of setting the value of the property foo.
> bar = self.foo and bar = [self foo] are equivalent means of getting the value of the property foo.
>
> This remains true if you name the instance variable the same as the property, but is typically considered more confusing. That is, if you use "@synthesize foo", you can still access "foo" and "self->foo" identically to _foo and self->_foo above.
It's OK, for some reason, I thought I had read that self->foo was no longer usable; my bad :-)
Joanna
--
Joanna Carter
Carter Consulting
_______________________________________________
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