Possible Duplicate:
Global int variable objective c
I would like to create a global variable.
I want to access to this variable anywhere.
The Java equivalent:
static var score:int = 0;
For example if I define a global variables into the Game class.
How to access to this global variable?
Game.score ?
If you are having multiple views in your application, and in that case you want to have a variable accessible to every view, you should always create a Model/Data class and define the variable in it. Something like this :
Objective-C :
Now in your view controller you need to call this method as :
This variable will be accessible to every view controller. You just have to create an instance of Data class.
Swift :
Usage :
DataClass.sharedManager.strUsing
dispatch_onceUsage :
DataClass.sharedManager.str