What class of Objective-C variable is this?

I work through some Objective-C code that I did not write, and found a variable declaration style that I am not familiar with. Can someone tell me about the scope of the variable myVar in the implementation of the class below? Note that this is displayed in the .m file, and not in the interface declaration.

@implementation MyClass
@synthesize ivar1, ivar2;

NSString* myVar; // <- What is the intent?

- (id)init {

...

@end

It seems to me that the intent is similar to the intent of a member variable. What are the benefits of declaring a variable this way instead of using ivar in the @interface declaration?

+3
source share
3 answers

. , ( , ). (.. .m) , extern:

extern NSString *myVar;

extern : " , ". extern .

+9

...

+2

I am not too experienced in ObjC, but I would say that it is global.

+1
source

Source: https://habr.com/ru/post/1710074/


All Articles