[英]Why am I getting error “invalid matchOutcome for participant”?
我试图在当前玩家退出此代码后结束基于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:”,因为它将导致相同的输出,因此请确保更新所需的任何必要数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.