What's the meaning of static variables in an implementation of an interface?
objective-c, static, static-variables, variables
Solution
The 'static' keyword in that context is the same as it would be in plain C: it limits the scope of myInt to the current file.
Problem
I don't quite understand static variables when defined in the implementation of an interface. In methods I do understand how they differ from local variables, but not when defined directly in an implementation. Look at these examples. What difference do these two make practically? ``` #include "MyClass.h" @implementation MyClass int myInt; ... @end ``` And: ``` #include "MyClass.h" @implementation MyClass static int myInt; ... @end ``` `myInt` is in both cases visible to all the methods, and if I interpreted a test I ran correctly, `myInt` will in both cases be the same variable for different instances of the class.