I have a static variable that I want to get from another class in the same project in X-Code. I declared it in the .h file and the .m file, gave it a value, and then when I turned to another class, I got an error message:
"Property 'xx' not found on object of type 'yy'"
i declared the variable as extern in .h and redefined it as the type of the variable in .m. I tried changing it to static in .h, but it still doesn't work. And yes, I imported the file containing the variable in case this is a problem.
Can anybody help me?
EDIT:
this is the code I'm using now:
source.h
static int anObject; @interface source : NSObject
source.m
static int a = 2 @implementation source
destination.m
# include "source.h" @implementation destination - (void) anObjectTestFunction { printf("%d", source.anObject);
now after I switched to the second version, the variable anObject in destination.h can be obtained, but its value is not 2, it is 0. I want it to match the one I declared in source.h.
source share