removeWithCompletionHandler错误
启动后,我试图通过在每个设备上调用此方法以编程方式清除设备之间的游戏中心服务器上的所有匹配:
/**
* called to authenticate the players game centre id
*/
- (void)authenticateLocalUser
{
if (!self.gameCentreAvailable) return;
NSLog(@"Authenticating Local User.");
if ([GKLocalPlayer localPlayer].authenticated == NO)
{
[[GKLocalPlayer localPlayer] setAuthenticateHandler:^(UIViewController* viewcontroller, NSError *error)
{
NSLog(@"Inside Authentication Handler.");
// if there was no error, and we got a valid view controller to display
if (!error && viewcontroller)
{
// get a handle to the app delegate
AppDelegate *delegate = [UIApplication sharedApplication].delegate;
// use the view controller in the app delegate to present the authentication view controller
[delegate.viewController presentViewController:viewcontroller animated:YES completion:
^{
// once the view controller has been displayed, register the change in authentication
[self authenticationChanged];
}];
// set this class as the event handler delegate
GKTurnBasedEventHandler *event = [GKTurnBasedEventHandler sharedTurnBasedEventHandler];
event.delegate = self;
}
// load all of the matches the player is currently a part of
[GKTurnBasedMatch loadMatchesWithCompletionHandler:^(NSArray *matches, NSError *error)
{
NSLog(@"Error loading matches: %@", error);
// for each match
for (GKTurnBasedMatch *match in matches)
{
// log the id of the match
NSLog(@"ID of match we are removing: %@", match.matchID);
// and then remove it
[match removeWithCompletionHandler:^(NSError *error)
{
NSLog(@"Error removing match: %@", error);
}];
}
}];
}];
}
else
NSLog(@"Already Authenticated.");
}
但是,该方法不起作用,相反,我在控制台中遇到了这个错误:
2012-11-05 08:32:39.699纺纱[6266:907]删除匹配时出错:错误域= GKErrorDomain代码= 17“请求的操作无法完成,因为一个或多个参数无效。” UserInfo = 0x1e5b2140 {NSLocalizedDescription =请求的操作无法完成,因为一个或多个参数无效。}
发生的唯一错误是在removeWithCompletionHandler中:其他一切都很好,并且没有错误。
任何帮助都是极好的。
从removeWithCompletionHandler的参考:
在将本地播放器作为主动参与者的匹配中调用此方法是一种编程错误。
http://developer.apple.com/library/ios/#documentation/GameKit/Reference/GKTurnBasedMatch_Ref/Reference/Reference.html
您没有检查以确保匹配适合删除。 在“删除”之前,您可能必须结束该用户的匹配。 此外,这种方法通常意味着用户通过选择而不是自动删除游戏。
链接地址: http://www.djcxy.com/p/65737.html上一篇: removeWithCompletionHandler Error
下一篇: Checking if a string contains a particular substring in Velocity