On 2011 Sep 23, at 15:57, Quincey Morris wrote: > a. What do you mean by "unnecessary"? Your choices for an outlet are pretty > much ivar or property. Are you suggesting the property is "unnecessary" > because it could be an ivar instead?
Yes. After studying this some more I see that, in older code, I did not declare outlets as properties. Instead, I put the IBOutlet directive on the ivar, @interface MyWinCon : NSWindowController { IBOutlet FooView *m_fooView ; } and then if I wanted other objects to be able to access these, instead of declaring a property I would declare and implement a getter - (FooView*)fooView { return m_fooView ; } > b. @dynamic isn't magic. It says the methods are provided by something else > (other than user-written implementations or @synthesized implementations). > What's the something else you're thinking of here? The "something" is that I thought the IBOutlet tells the compiler to access instance variables directly. After reading Greg Parker's responses and the links, I see that the executable actually is different if an outlet is @synthesize vs. @dynamic. If you use @synthesize, it really does synthesize setters and getters, and these really are used during nib loading. If you use @dynamic, setters and getters are not synthesized, and nib loading accesses instance variables directly using, for instance, object_setInstanceVariable(). So now I understand that if an outlet is declared as an @property, as Xcode has been doing in recent versions, it needs to be implemented, for example by @synthesize. Using @dynamic would be wrong because it allows me to write code that invokes, e.g., -[MyWinCon fooView], which would cause a "method not found for selector" runtime exception. Actually, the old way still seems more straightforward, but anyhow I see how it works now. Thank y'all. _______________________________________________ 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