我遇到与此主题相同的问题:What causes "Missed Method" in this code?
但我不明白如何解决这个问题,或者它是否是一个问题。
我正在阅读“开始iOS游戏中心和游戏工具包”一书中的教程,并解决了这个问题。我总是得到“......错过的方法”并试图理解为什么,不幸的是我没有。我也尝试在上面的帖子中使用答案,但无济于事。
我非常感谢这方面的一些帮助。
我目前使用的代码:
#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
答案 0 :(得分:0)
您对调用[self callDelegateOnMainThread:@selector(processGameCenterAuthentication:) withArg:NULL error: error];
进行编码,该调用最终以方法(callDelegate:withArg:error:
)结束,该方法检查您的类是否实现了processGameCenterAuthentication:
方法。您得到Missed Method
输出,因为您似乎没有实现它。