In the following code, I get '(null)' for the second line in the output but not the fourth.
MyClass.h
@interface MyClass : NSObject
@property (readonly) NSString *foo;
@property (getter=getBar, readonly) NSString *bar;
@end
main.m
@implementation MyClass
- (NSString *)getFoo { return @"foo"; }
- (NSString *)getBar { return @"bar"; }
@end
int main(int argc, const char * argv[]) {
@autoreleasepool {
MyClass *myClassInstance = [MyClass new];
NSLog(@"%@", myClassInstance.getFoo);
NSLog(@"%@", myClassInstance.foo);
NSLog(@"%@", myClassInstance.getBar);
NSLog(@"%@", myClassInstance.bar);
}
return 0;
output
foo
(null)
bar
bar
Why am I seeing this?