在当前玩家退出此代码后,我试图结束基于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/