• 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: inherited implicitly created member is no member?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: inherited implicitly created member is no member?


  • Subject: Re: inherited implicitly created member is no member?
  • From: Greg Parker <email@hidden>
  • Date: Tue, 1 Feb 2011 19:50:29 -0800

On Feb 1, 2011, at 7:42 PM, Kyle Sluder wrote:
> On Tue, Feb 1, 2011 at 7:31 PM, Matt Neuburg <email@hidden> wrote:
>> Wait, you're going too fast for me. You say this makes no guarantee about the storage, but in fact an ivar "text" does get generated, since I can say self->text in the superclass; that's the whole point of implicit ivar generation. So what does the superclass know that the subclass doesn't? Thx - m.
>
> The @property declaration isn't want generates the ivar. It's the @synthesize declaration that creates the ivar.

Precisely. Your subclass only sees @property, but there's no guarantee that a property has a matching ivar with the same name.

In addition, when @synthesize does create an ivar, the ivar it creates is @private. So even if your subclass did know about the @synthesize (not impossible), it still would not be allowed to access the ivar directly.

All of this is intentional. The goal is for these constructs to create private data by default. If you want subclasses or other classes to be able to bypass your setters and getters, you have to type extra code to allow it. In this case, you can explicitly declare a non-@private ivar in your @interface.


--
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: inherited implicitly created member is no member?
      • From: Matt Neuburg <email@hidden>
References: 
 >inherited implicitly created member is no member? (From: Matt Neuburg <email@hidden>)
 >Re: inherited implicitly created member is no member? (From: Kyle Sluder <email@hidden>)
 >Re: inherited implicitly created member is no member? (From: Matt Neuburg <email@hidden>)
 >Re: inherited implicitly created member is no member? (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: inherited implicitly created member is no member?
  • Next by Date: Re: Bizarre behaviour of NSFontDescriptor and/or NSCharacterSet
  • Previous by thread: Re: inherited implicitly created member is no member?
  • Next by thread: Re: inherited implicitly created member is no member?
  • Index(es):
    • Date
    • Thread