我是Objective-C的新手,但我很好奇我在其他任何地方都没有看过的东西.
谁能告诉我在@interface
块中声明的私有变量与@implementation
在类方法之外的块中声明的变量之间的区别是什么,即:
@interface Someclass : NSObject {
NSString *forExample;
}
@end
Run Code Online (Sandbox Code Playgroud)
与
@implementation Someclass
NSString *anotherExample;
-(void)methodsAndSuch {}
@end
Run Code Online (Sandbox Code Playgroud)
似乎两个变量(forExample
,anotherExample
)在整个班级中都可以同等地访问,我无法真正发现他们的行为有所不同.第二种形式也称为实例变量吗?
objective-c ×1