GKTurnBasedMatch members are incorrect / duplicated

I am working on a turn-based game GameCenter. A GKTurnBasedMatch is created using GKMatchRequest , with minPlayers and maxPlayers set to 2. I get an NSInvalidArgumentException when I try to end the game using endMatchInTurnWithMatchData , telling me that I did not set matchOutcome for all participants. The logs for the match object right before this point show that my match is as follows:

 <GKTurnBasedMatch 0x1c1f2af0 - matchID:c9de6e47-0e9a-4dbe-944b-d2fd4ecd3044 bundleID:com.mybundle.wd status:GKTurnBasedMatchStatusEnded message:'Game Over' creationDate:2013-10-08 01:26:12 +0000 currentParticipant:(null) participants: <GKTurnBasedParticipant 0x1c184820 - playerID:G:128458444 (local player) status:Done matchOutcome:Lost lastTurnDate:2013-10-10 21:54:22 +0000 timeoutDate:(null)>, <GKTurnBasedParticipant 0x1c1b0a80 - playerID:G:220673962 status:Done matchOutcome:Lost lastTurnDate:2013-10-10 18:26:16 +0000 timeoutDate:(null)>, <GKTurnBasedParticipant 0x16ef1610 - playerID:G:128458444 (local player) status:Active matchOutcome:None lastTurnDate:(null) timeoutDate:(null)>, <GKTurnBasedParticipant 0x16ec64f0 - playerID:(null) status:Matching matchOutcome:None lastTurnDate:(null) timeoutDate:(null)> matchData.length:871 matchDataMaximumSize:65536 exchanges:(null)> 

I have more than 2 GKTurnBasedParticipants , and two of them are the same player! I am not doing anything extraordinary in the game, except that you call the following move:

 [match endTurnWithNextParticipants:@[nextParticipant] turnTimeout:GKTurnTimeoutDefault matchData:data completionHandler:^(NSError *error){...}] 

Does anyone know what is going on here? This is a two-player game, since I can get into the object of a confused match, and how can I prevent this?

+6
source share
2 answers

I do the following to finish the game

  ((GKTurnBasedParticipant*)[currentMatch.participants objectAtIndex:1]).matchOutcome = GKTurnBasedMatchOutcomeWon; ((GKTurnBasedParticipant*)[currentMatch.participants objectAtIndex:0]).matchOutcome = GKTurnBasedMatchOutcomeLost; 

then i call

 [currentMatch endMatchInTurnWithMatchData:data completionHandler:^(NSError *error) { if (error) { NSLog(@"%@", error); } else{ } }]; 
0
source

I sent an error with Apple and four months later received this via email:

Hi, Kirill,

This is a continuation with respect to error identifier No. 15615850.

We believe that this issue has been addressed. Please check with iOS 7.1 beta 4 (11D5134c) and update the report with the results.

So - yes, this is confirmed as an error, I still do not know the workaround, but as soon as 7.1 comes out, we will get rid of it.

0
source

Source: https://habr.com/ru/post/955718/


All Articles