• 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: Fri, 23 Sep 2011 19:30:11 -0700

On Sep 23, 2011, at 7:21 PM, Charles Srstka wrote:
> On Sep 23, 2011, at 6:06 PM, Greg Parker wrote:
>>
>> Nib connection on iOS uses KVC. Nib connection on OS X does not use KVC itself, but it does use a similar "call method if it exists, set ivar directly if it does not" algorithm.
>
> But how does that work? If I make the IBOutlet an ivar, make it @private, and have +accessInstanceVariablesDirectly return NO, trying to access this ivar directly from another object causes a compiler error, and trying to access it via KVC throws a “not key value coding-compliant for the key <outlet name>” exception. Yet the nib loading mechanism is still able to set the ivar. I’ve always been curious about why exactly this works.

On OS X, nib connection does not use KVC. Since it's not using KVC, it pays no attention to KVC machinery like +accessInstanceVariablesDirectly.

The OS X nib connection implementation calls object_setInstanceVariable(). This function, like all of the runtime's introspection functions, ignores compile-time access controls.


--
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

  • Follow-Ups:
    • Re: Why does Xcode define IBOutlet with @synthesize?
      • From: Charles Srstka <email@hidden>
References: 
 >Why does Xcode define IBOutlet with @synthesize? (From: Jerry Krinock <email@hidden>)
 >Re: Why does Xcode define IBOutlet with @synthesize? (From: Charles Srstka <email@hidden>)
 >Re: Why does Xcode define IBOutlet with @synthesize? (From: Greg Parker <email@hidden>)
 >Re: Why does Xcode define IBOutlet with @synthesize? (From: Charles Srstka <email@hidden>)

  • Prev by Date: Re: Why does Xcode define IBOutlet with @synthesize?
  • 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