• 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: Greg Parker <email@hidden>
  • Date: Tue, 27 Sep 2011 13:43:20 -0700

On Sep 27, 2011, at 10:06 AM, Matt Neuburg wrote:
> 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.

If you use ARC, that conflict goes away. KVC does the right thing with ARC weak or strong or unsafe-unretained ivars. KVC looks for ARC's ivar metadata and performs the same memory management as ARC would have.


--
Greg Parker     email@hidden     Runtime Wrangler


_______________________________________________

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

References: 
 >Re: Why does Xcode define IBOutlet with @synthesize? (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: controller question
  • Next by Date: debugging crashes in dyld?
  • Previous by thread: Re: Why does Xcode define IBOutlet with @synthesize?
  • Next by thread: What is the likely reason why objects aren't being loaded from a XIB?
  • Index(es):
    • Date
    • Thread