Re: inherited implicitly created member is no member?
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