<分区>
这两者有什么区别:
@interface MyClass ()
{
BOOL newUser;
}
或者
@implementation MyClass
{
BOOL newUser;
}
@end
标签 ios objective-c
<分区>
这两者有什么区别:
@interface MyClass ()
{
BOOL newUser;
}
或者
@implementation MyClass
{
BOOL newUser;
}
@end
最佳答案
在您的接口(interface)中声明的变量,如在 1. 中,在实例化 MyClass 对象的其他类中是可见的。 2. 中声明的变量只会在 MyClass 内部可见。 这是您应该阅读的内容: http://developer.apple.com/library/ios/#referencelibrary/GettingStarted/Learning_Objective-C_A_Primer/
编辑:@JoshCaswell 是对的。 1.是匿名类。根据声明接口(interface)的位置,可以看到它的变量。一个更好的阅读链接是: http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/ProgrammingWithObjectiveC/CustomizingExistingClasses/CustomizingExistingClasses.html
关于ios - Objective-C 中的变量声明——接口(interface)与实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17956605/
相关文章:
ios - UICollectionView 防止多次点击/调用 didSelectItemAt
ios - Xcode 5.1.1 未加载且无法连接 iPad
ios - 如何将弱引用对象存储在数组中,objc中的字典?
iphone - iOS 5 不允许将下载的数据存储在 Documents 目录中?
ios - UICollectionView 和访问 UICollectionViewCell
ios - Travis CI - 无法查询测试包中的测试用例列表 : Test bundle not found
ios - NSOperationQueue mainQueue vs performSelectorOnMainThread?