• 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: Retain/Release and Properties clarification
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Retain/Release and Properties clarification


  • Subject: Re: Retain/Release and Properties clarification
  • From: David Duncan <email@hidden>
  • Date: Tue, 11 Oct 2011 10:12:00 -0700

On Oct 11, 2011, at 9:57 AM, Matt Neuburg wrote:

> I did everything "right" when I named an ivar "firstResponder" (property, synthesized ivar, synthesized accessors) and totally broke my app because Apple was apparently already using an undocumented ivar called "firstResponder".
>
> http://www.cocoabuilder.com/archive/cocoa/296662-assign-property-behaves-differently-from-simple-instance-variable.html

The problem wasn't an undocumented ivar, it was an undocumented method. The @synthesize thus overrode the existing method and broke your project because parts of UIKit were expecting the default implementation and got your implementation instead.

As a rule, we strive to avoid this situation, but unfortunately this does happen on occasion.

> Also, note that there are circumstances where a synthesized ivar won't work; see, for instance, this note:
>
> http://www.cocoabuilder.com/archive/cocoa/298320-inherited-implicitly-created-member-is-no-member.html

The gist of this is that synthesized ivars are private, and the public interface (the @property) doesn't tell you about private implementation details (the ivar). As such, subclasses can't get at synthesized ivars, precisely because the @synthesize declaration is hidden from them.
--
David Duncan

_______________________________________________

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: Retain/Release and Properties clarification
      • From: Bayes Scott F <email@hidden>
References: 
 >Re: Retain/Release and Properties clarification (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: Scripting Bridge Finder
  • Next by Date: "diskutil info -plist" via Cocoa object?
  • Previous by thread: Re: Retain/Release and Properties clarification
  • Next by thread: Re: Retain/Release and Properties clarification
  • Index(es):
    • Date
    • Thread