• 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: John Joyce <email@hidden>
  • Date: Wed, 2 Feb 2011 12:24:32 +0900

On Feb 2, 2011, at 12:14 PM, Matt Neuburg wrote:

> I got a little surprise today:
>
> @interface MySuperClass : NSObject {
> }
> @property (nonatomic, copy) NSString* text;
> @end
>
> @implementation MySuperClass
> @synthesize text;
> @end
>
> @interface MySubClass : MySuperClass...
>
> And now, in MySubClass, if I try to talk about self->text, I get:
>
>  'struct MySubClass' has no member named 'text' (or the GCC equivalent)
>
> Of course I can fix this in several ways, of which the most obvious is to declare the ivar "text" explicitly in the interface for MySuperClass. But I'm curious; why does it happen? I thought declaring the property without the ivar meant that I was implicitly creating the ivar. And as far as the superclass is concerned, it does mean that. Why doesn't the subclass know about this? Thx! m.
>
Property declaration tells the compiler to synthesize accessor methods, not the ivars.

You might be missing the @dynamic keyword in the implementation section, but it doesn't necessarily synthesize the ivar either.

@dynamic text;

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocProperties.html

_______________________________________________

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

  • Prev by Date: Re: inherited implicitly created member is no member?
  • Next by Date: Re: inherited implicitly created member is no member?
  • 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