On Apr 27, 2011, at 9:09 AM, Joanna Carter wrote:

> I too would like to see a means of explicitly accessing the ivar, even if it 
> has the same name as the property; although, I thought that not calling 
> self.property from within the .m file defaulted to accessing the ivar if both 
> it and a property existed?


Given:
@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.
--
David Duncan

_______________________________________________

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

Reply via email to