那么什么是真正的这两个版本之间的区别:私人和公共财产
@interface Foo : NSObject
// A guy walks into a bar.
@property(nonatomic, copy) NSString *bar;
@end
// Implementation file
@interface Foo()
@property(nonatomic, retain) NSArray *baz;
@end
和
@interface Foo : NSObject
// A guy walks into a bar.
@public
@property(nonatomic, copy) NSString *bar;
@private
@property(nonatomic, retain) NSArray *baz;
@end
至于我的理解去,把@property在.m基本上意味着它是私人的。纠正我,如果我错了?那么哪个是最好的实现呢?这只是一种编码风格/练习吗?
我实际上有点惊讶,编译器没有将@ public/@ private直接放入@interface直接像这样...... – bbum
@bbum编译器**确实**呛在那个代码上 –
我发现[本文](http://swish-movement.blogspot.com/2009/05/private-properties-for-iphone-objective.html)有用。 – DanSkeel