【发布时间】:2012-02-03 01:07:43
【问题描述】:
将伪私有实例变量放在 .m 文件内的类扩展中,或者将它们放在新引入的@implementation 括号中,如下所示有什么区别?
其中一种或另一种方式是否有后果、优点、缺点? internal2 是否以程序员必须关心的方式与 internal3 区别对待? (当然,McKay 会说有所不同,但问题是你在实践中是否关心)。
// MyClass.m
@interface MyClass () {
id internal2;
}
@end
@implementation MyClass {
id internal3;
}
- (void)internalMethod {
NSLog(@"%@ %@", internal2, internal3);
}
@end
来源:http://www.mcubedsw.com/blog/index.php/site/comments/new_objective-c_features/
【问题讨论】:
标签: objective-c ios