|
|
|
|
|
by b3morales
1654 days ago
|
|
This is in fact how @property works; the declaration is sugar for a pair of accessor methods. The dot syntax is sugar for calling those methods. #include <Foundation/Foundation.h>
@interface Foo : NSObject
@property (copy) NSString *bar;
@end
@implementation Foo
@end
int main(int argc, char *argv[]) {
Foo *foo = [Foo new];
[foo setBar:@"Hello, world!"];
NSLog(@"%@", [foo bar]);
return 0;
}
|
|
Objective-C was grafted onto C with very clear demarcation lines.
We don’t mind being able to declare a property with `@property`. We do mind that they introduced dot syntax