I just implemented game center support in my app like it’s described here How To Make A Simple Multiplayer Game with Game Center Tutorial: Part 1/2.
It is realized as a singleton. In my app delegate:
// At the end of applicationDidFinishLaunching, right before
// the last line that calls runWithScene:
[[GCHelper sharedInstance] authenticateLocalUser];
A little overview over the methods and attributes:
@interface GCHelper : NSObject {
BOOL gameCenterAvailable;
BOOL userAuthenticated;
}
@property (assign, readonly) BOOL gameCenterAvailable;
+ (GCHelper *)sharedInstance;
- (void) authenticateLocalUser;
@end
Since there is now reference to the GCHelper in my app delegate I wonder how to actually test in an other class (where I submit score) if game center is available.
How do I get the singleton instance of GCHelper in another class?
Just see how I get the instance of singleton class in another class :
//DataClass.h
//DataClass.m
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.