I have question about global variable in Objective-C.
I have two .m files : file1.m and file2.m, and one .h file : file.h
I want to declare a global variable in .h and this variable has two different values defined by .m files.
I do this :
In .h file :
extern NSString * const myVar;
In file1.m :
NSString * const myVar = @"value 1";
In file2.m :
NSString * const myVar = @"value 2";
But it doesn’t link, I have error “duplicate symbols”.
I understand this error, but I can’t solve it to do what I want.
Any help ?
Do not declare it in the .h file, but declare it in each .m file where you use it (like now) and put “static” in front of the declaration