Wednesday, December 16, 2009

Global variable in Obj c

It is simple. In any .h file, write:
Code:

extern int variable;

Put this declaration *outside* of any Objective-C block like @interface...@end. You can place it before the @interface or after the @end. Either way is just fine.

Then, define the variable in any .m file (it doesn't matter which one, but only place it in one file):

Code:

int variable;

No comments:

FEEDJIT Live