• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Why does Xcode define IBOutlet with @synthesize?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why does Xcode define IBOutlet with @synthesize?


  • Subject: Re: Why does Xcode define IBOutlet with @synthesize?
  • From: Matt Neuburg <email@hidden>
  • Date: Tue, 27 Sep 2011 10:06:50 -0700

On Fri, 23 Sep 2011 22:08:43 -0700, Jerry Krinock <email@hidden> 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.

--
matt neuburg, phd = email@hidden, <http://www.apeth.net/matt/>
A fool + a tool + an autorelease pool = cool!
Programming iOS 4!
http://www.apeth.net/matt/default.html#iosbook_______________________________________________

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

  • Follow-Ups:
    • Re: Why does Xcode define IBOutlet with @synthesize?
      • From: Greg Parker <email@hidden>
    • Re: Why does Xcode define IBOutlet with @synthesize?
      • From: David Duncan <email@hidden>
  • Prev by Date: Re: Core Data : Undo Delete : Cannot fulfill a fault
  • Next by Date: Re: Why does Xcode define IBOutlet with @synthesize?
  • Previous by thread: Re: Why does Xcode define IBOutlet with @synthesize?
  • Next by thread: Re: Why does Xcode define IBOutlet with @synthesize?
  • Index(es):
    • Date
    • Thread