ios - 为什么会出现错误“参与者的无效matchOutcome”?

标签 ios objective-c game-center

在当前玩家退出此代码后,我试图结束基于2玩家回合制的游戏:

NSUInteger currentIndex = [match.participants indexOfObject:match.currentParticipant];
GKTurnBasedParticipant *curr = match.currentParticipant;
GKTurnBasedParticipant *next = [match.participants objectAtIndex:(currentIndex + 1)%[match.participants count]];

[match participantQuitInTurnWithOutcome:GKTurnBasedMatchOutcomeQuit
                           nextParticipants:@[next]
                                turnTimeout:MAXFLOAT
                                  matchData:matchData
                          completionHandler:^(NSError *error) {
                              if (error) {
                                  NSLog(@"%@", error);
                              }


                              [curr setMatchOutcome:GKTurnBasedMatchOutcomeQuit];
                              [next setMatchOutcome:GKTurnBasedMatchOutcomeWon];

                              [match endMatchInTurnWithMatchData:matchData
                                               completionHandler:nil

但是我得到了错误:
由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“参与者的无效matchOutcome”

有什么想法吗?

最佳答案

通过调用类func“loadMatchWithID:”重新更新您的匹配项

然后在设置每个参与者的matchOutcome之后调用“endMatchInTurnWithMatchData:”。

由于您的数据不同步,您可能会收到此错误“原因:'与参与者无效的matchOutcome'”。

替代------------>
或者,您可以使用“endMatchInTurnWithMatchData:”,因为它将产生相同的输出,只需确保更新所需的任何必要数据即可。

关于ios - 为什么会出现错误“参与者的无效matchOutcome”?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24023695/

相关文章:

ios - 如何从 UIMenuController 中删除默认菜单项?

ios - 在核心数据中遍历关系时重新获取对象

ios - 使用带有自定义键的 KVO

ios - 是否可以将用户生成的内容存储在 Game-Center 上并在所有用户之间共享?

ios - 在 ios5 中集成 paypal mpl 的问题(paymentFailedWithCorrelationID :) (paymentLibraryExit)

ios - 苹果推送通知可以发送比警报和声音更多的参数吗?

ios - 与 View Controller 内的自定义 UIView 交互

ios - 尽管有 4G,但一台设备的可达性返回 "NotReachable"

iphone - 游戏中心邀请失败

iphone - 多个设备上的 Game Center 沙箱