I'm new to Objective-C, but I am curious about something that I haven't really seen addressed anywhere else.
Could anyone tell me what is the difference between a private variable that is declared at the @interface
block versus a variable that is declared within the @implementation
block outside of the class methods, i.e:
@interface Someclass : NSObject {
NSString *forExample;
}
@end
vs.
@implementation Someclass
NSString *anotherExample;
-(void)methodsAndSuch {}
@end
It seems both variables ( forExample
, anotherExample
) are equally accessible throughout the class and I can't really find a difference in their behaviour. Is the second form also called an instance variable?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…