Game Development Reference
In-Depth Information
...
Note that you're responsible for setting the GameKitHelper delegate back to nil
when appropriate—for example, shortly before changing scenes. Because
GameKitHelper keeps a reference to the delegate, ARC won't release the delegate
object from memory. That would not only keep the delegate itself in memory but all of
its member variables as well, including all its children if it's a CCNode class.
Checking for Game Center Availability
The GameKitHelper class starts by checking for Game Center availability right in
its init method ( Listing 14-3 ) . It needs to do that only once because the conditions
never change while the app is running.
Listing 14-3 . Testing for Game Center Availability
-(id) init
{
if ((self = [super init]))
{
// Test for Game Center availability
Class gameKitLocalPlayerClass = NSClassFromString(@"GKLocalPlayer");
BOOL isLocalPlayerAvailable = (gameKitLocalPlayerClass != nil);
// Test if device is running iOS 4.1 or higher
NSString* reqSysVer = @"4.1";
NSString* currSysVer = [UIDevice currentDevice].systemVersion;
BOOL isOSVer41 = ([currSysVer compare:reqSysVer
options:NSNumericSearch] != NSOrderedAscending);
isGameCenterAvailable = (isLocalPlayerAvailable && isOSVer41);
NSLog(@"GameCenter available = %@", isGameCenterAvailable ? @"YES" : @"NO");
[self registerForLocalPlayerAuthChange];
}
 
 
Search Nedrilad ::




Custom Search