【发布时间】:2012-07-03 11:54:36
【问题描述】:
我有如下类接口:
@interface MyClass : NSObject
@property int publicProperty;
@end
然后是实现:
@interface MyClass() // class extension
- (void)privateMethod; // private methods
@end
@implementation MyClass {
int _privateProperty;
}
@property int privateProperty = _privateProperty;
@end
这是苹果人在 WWDC 中展示的内容,但有什么理由不将 _privateProperty 放在类扩展中,例如:
@interface MyClass() // class extension
{
int _privateProperty;
}
- (void)privateMethod; // private methods
@end
谢谢!
【问题讨论】:
-
您可能会在这里找到很多很好的问题答案:stackoverflow.com/search?q=private+property
标签: objective-c implementation private class-extensions