On Tue, Feb 1, 2011 at 7:31 PM, Matt Neuburg <[email protected]> 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 protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to