Can anyone explain to me what a singleton object is? In many tutorials I found something like “create a sigleton object”. Now I am working in iphone game development using cocos2d. I read “Create a singleton object to keep all the Game Center code in one spot” in raywenderlich multiplayer tutorial, and also he says:
+ (GCHelper *)sharedInstance;
This static method to retrive the singleton instance of this class. But I don’t know what a singleton is, or how to use it.
A Singleton object is an object for which there is only a single instance for a given class. The Singleton pattern is used when you want to guarantee that a single instance of a class will be shared across clients in a system.
Check out the C2 wiki page for more information.
Here are some posts with examples of the use of singletons in objective-c: