objective c - Access static variables in ObjC categories -
i'm trying implement category of existing class. there static variable in existing class. if try access static variable category, i'm getting error static variable undeclared.
is possible access static variables in objc categories ?
just clear, objective-c doesn't associate static variables classes. static variables scoped default whatever file they're declared in.
to make static variable visible in other files, add declaration in corresponding header file prefixed keyword extern
. example, if had defined following static variable somewhere in 1 of .m files
int seconds = 60;
you add following declaration in .h file:
extern int seconds;
then, .m file imports .h file see static variable.
Comments
Post a Comment