On Oct 12, 2011, at 9:21 AM, Bayes Scott F wrote:
> Someone on Matt's site mentioned the possibility that the synthesized ivar 
> could be implemented indirectly, say as a member of a collection. Since the 
> implementation's opaque, we don't know if that ever can happen.

A property may be implemented using storage that is not an ivar. 
NSManagedObject uses this.

A *synthesized* property will always use an ivar. That's part of the definition 
of @synthesize.


> So, is self->mySynthIvar safe (both lvalue and rvalue), or should we be 
> messaging?

If it's your property, then you're free to access the ivar yourself. Of course, 
direct ivar access may bypass any atomicity or memory management behavior that 
the getter and setter methods enforce.


> And does the compiler ever shortcut something like self.mySynthSimpleIntVar 
> to self->mySynthSimpleIntVar, or does it always use the setter/getter?

Never. Omitting the method call would be an incorrect optimization, because 
(for example) KVO might override the method to perform KVO change 
notifications. To make that optimization safely, you would need something like 
runtime recompilation that could undo the optimization at runtime if necessary.


-- 
Greg Parker     gpar...@apple.com     Runtime Wrangler


_______________________________________________

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