Instance variables usually do not need to be explicitly specified. They are created when you @synthesize property. If you really want them, then the (new) right place * is at the top of the implementation block:
@implementation Level { PlayBackgroundLayer* playBGLayer; PlayUILayer* playUILayer; PlayElementLayer* playElementLayer; }
These are not static methods, these are class methods , but yes, this is where you declare them. Some people like @property declarations before classes, but this is a matter of opinion. Instance methods come after both of them, although technically speaking the order doesn't matter - that is, the compiler doesn't care, it's just a matter of readability.
However, these top-level variables should go somewhere other than the header file. If you put them in there, you will get compilation errors, because every file that imports the header seems to re-declare storage for these variables, which is not allowed.
Usually you put such variables in a .m file. If you want them to be visible only there, you would use static . If you want them to be visible from other files that import the header, you leave static turned off and declare the variable as extern in the header:
extern Level* currentLevel;
This allows the compiler to know that the storage for the variable is reserved elsewhere.
* See "Class Interface" in TOCPL.
Josh caswell
source share