mardi 4 août 2015

Objective-C: What does getter= actually do in @property?

This code:

@interface SomeClass : NSObject

@property(getter=myProp) NSString *prop;

@end

@implementation AnotherClass

- (void)test {
    SomeClass *s = [[SomeClass alloc] init];
    NSString *x = s.prop;
    NSString *y = s.myProp;
}

@end

Both x and y are the value of the same property, I got two getters, one is -myProp and the other is -prop, so does declaring getter add another getter besides the auto-generated getter?

If this is right, can I use getter= to generate more than one getter?

Also, how do I remove the auto-generated -prop getter?

Aucun commentaire:

Enregistrer un commentaire