我在这个线程中遇到了同样的问题:是什么导致了这段代码中的“错过方法”?
但我不明白如何解决这个问题,或者它是否是一个问题。
我正在做“Beginning iOS Game Center and Game Kit”一书中的教程并遇到这个问题。我总是得到“......错过的方法”,并试图理解为什么,不幸的是我没有。我也尝试使用上面线程上的答案,但无济于事。
我非常感谢对此提供的一些帮助。
我目前使用的代码:
#import "GameCenterManager.h"
@implementation GameCenterManager
@synthesize delegate;
+(BOOL)isGameCenterAvailable {
Class gcClass = (NSClassFromString(@"GKLocalPlayer"));
NSString *reqSysVer = @"4.1";
NSString *currSysVer = [[UIDevice currentDevice]systemVersion];
BOOL osVersionSupported = ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending);
return (gcClass && osVersionSupported);
}
-(void)retrieveFriendsList {
if ([GKLocalPlayer localPlayer].authenticated == YES) {
[[GKLocalPlayer localPlayer]loadFriendsWithCompletionHandler:^(NSArray *friends, NSError *error) {
[self callDelegateOnMainThread:@selector(friendsFinishLoading:error:) withArg:friends error:error];
}];
} else {
NSLog(@"...You must authenticate first");
}
}
-(void)authenticateLocalUser {
if ([GKLocalPlayer localPlayer].authenticated) {
return;
}
[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error){
[self callDelegateOnMainThread:@selector(processGameCenterAuthentication:) withArg:NULL error: error];
}];
}
-(void)callDelegateOnMainThread:(SEL)selector withArg: (id) arg error:(NSError*) err {
dispatch_async(dispatch_get_main_queue(), ^(void) {
[self callDelegate:selector withArg: arg error: err];
});
}
-(void)callDelegate: (SEL) selector withArg: (id) arg error: (NSError*) err {
assert([NSThread isMainThread]);
if ([delegate respondsToSelector: selector]) {
if(arg != NULL) {
[delegate performSelector: selector withObject: arg withObject: err];
} else {
[delegate performSelector: selector withObject: err];
}
} else {
NSLog(@"...Missed Method");
}
}
GC授权后输出:
...Missed Method