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: Kyle Sluder <email@hidden>
- Date: Tue, 1 Feb 2011 19:42:19 -0800
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. Furthermore, if the
compiler doesn't find a definition of the methods -text or -setText:
in the same @implementation block as the @synthesize declaration, it
will create definitions of those methods for you.
You can use the @synthesize=some_other_name syntax to prove this to yourself:
///// file synth.m
#import <Foundation/Foundation.h>
@interface MyClass : NSObject
@property(assign) id propName;
@end
@implementation MyClass
@synthesize propName=someOtherName;
- (void)someMethod {
self->propName = nil;
}
@end
///// end synth.m
% clang -c /tmp/synth.m -o /tmp/synth.o
/tmp/synth.m:13:11: error: 'MyClass' does not have a member named 'propName'
self->propName = nil;
~~~~ ^
1 error generated.
--Kyle
_______________________________________________
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