Class variable defined at @implementation rather than @interface?

Posted by bitcruncher on Stack Overflow See other posts from Stack Overflow or by bitcruncher
Published on 2010-04-03T14:35:56Z Indexed on 2010/04/03 14:43 UTC
Read the original article Hit count: 257

Filed under:

Hello. 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?

© Stack Overflow or respective owner

Related posts about objective-c