Class global variables in Objective-C -


i'm trying create variables can accessed class coming java background i'm struggling understand in objective-c..

in java have:

public static int main_menu = 1, selection_screen = 2; 

these can accessed anywhere so:

classname.main_menu; 

how achieve same thing in simplest form objective-c keeping within class?

in objective-c, classes have no static members. best can imagine creating getter , setter class method utterly ugly global variable:

static t _member = initialvalue;  + (t)somestaticmember {     return _member; }  + (void)setsomestaticmember:(t)newval {     _member = newval; } 

if need getter, i. e. emulation of read-only member, move static variable inside function, @ least have 1 less global way.


but: if need integer constants, why not use enum? or @ least macros?


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -