我在这里学习教程。多人游戏 iOS
我正在使用上面教程中的以下代码进行匹配
GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease];
request.minPlayers = minPlayers;
request.maxPlayers = maxPlayers;
request.playersToInvite = pendingPlayersToInvite;
GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithMatchRequest:request] autorelease];
mmvc.matchmakerDelegate = self;
[presentingViewController presentModalViewController:mmvc animated:YES];
当我使用“立即播放”选项搜索其他玩家时,GKMatchmakerViewController
立即被解雇matchmakerViewController:didFailWithError
并出现以下错误。
Error Domain=GKErrorDomain Code=3 "The requested operation could not be
completed due to an error communicating with the server." UserInfo=0x2081d8d0
{GKServerStatusCode=5001, NSUnderlyingError=0x2086c560 "The operation couldn’t be
completed. (GKServerErrorDomain error 5001.)", NSLocalizedDescription=The requested
operation could not be completed due to an error communicating with the server.}
我一直无法弄清楚为什么会这样。相同的代码之前能够搜索和找到合适的玩家,但在使用获取玩家别名时失败了
[GKPlayer loadPlayersForIdentifiers:match.playerIDs withCompletionHandler:^(NSArray *players, NSError *error)
出现“无法与服务器通信”错误。
但是,该代码在模拟器上运行良好。