4
如何做到这一点:公开API只读,但内部读/写?
@interface Foo : NSObject
@property (readonly) int bar;
@end
...
@interface Foo()
@property (nonatomic) int bar;
@end
@implementation Foo
@synthesize bar = _bar;
// stuff that does self.bar = 123;
@end
使一些外部类不能调用foo.bar = 123 ..但里面的Foo的内部方法可以...?