簡體   English   中英

為什么會出現錯誤“參與者的無效matchOutcome”?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM