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

Popular posts from this blog

c++ - Compiling static TagLib 1.6.3 libraries for Windows -

PostgreSQL 9.x - pg_read_binary_file & inserting files into bytea -

asp.net - call stack missing info on mono with apache and mod_mono -