On Sep 27, 2011, at 10:06 AM, Matt Neuburg wrote: > On Fri, 23 Sep 2011 22:08:43 -0700, Jerry Krinock <je...@ieee.org> said: > >> 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 ; >> } > > I would just add (perhaps unnecessarily) that on iOS, where KVC is used, one > should not be tempted to use a pure ivar instead of property + synthesized > accessor, because when KVC sets an ivar directly it retains it and your whole > memory management scheme can be thrown off. (This is just one of many reasons > why direct KVC access to ivars is scary.) The property, with its declared > memory management policy, and the synthesized accessor that implements that > policy, acts as a memory management gateway to ward off KVC's curious and > probably unwanted memory management behavior. > > I don't remember whether there are similar memory management considerations > on OS X, but presumably not. m.
Anytime KVC must directly access an instance variable it does this (it maybe considered curious by some, but it is also the tactic that yields the least surprise – imagine if KVC set a value and it became invalid because there were no longer any owning references). The reason why nib loading doesn't do this on Mac OS X is that nib loading there doesn't use KVC, but rather then Obj-C runtime directly. -- 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