1

Let's say there is a GKTurnBasedMatch with only 2 participants left that haven't quit yet.

If the current participant wants to quit, instead of calling, participantQuitInTurnWithOutcome:... is it correct to call, endMatchInTurnWithMatchData:... since the match can't continue with only one participant?

But if the other participant wants to quit, you can't call endMatchInTurnWithMatchData:... since it is not your turn, so you would have to call participantQuitOutOfTurnWithOutcome:... but then you are left with a single participant in the match.

What is the correct way to handle these situations?

4

1 回答 1

1

you can call –participantQuitOutOfTurnWithOutcome:withCompletionHandler: then -(void)handleTurnEventForMatch:(GKTurnBasedMatch *)match didBecomeActive:(BOOL)didBecomeActive from GKTurnBasedEventHandlerDelegate will be called for all other participants.

There you can call -(void)endMatchInTurnWithMatchData:(NSData *)matchData completionHandler:(void (^)(NSError *error))completionHandler for player whose turn is now.

To determine, who left your match, check GKTurnBasedParticipant's property matchOutcome - it will be GKTurnBasedMatchOutcomeQuit.

于 2012-12-11T13:42:28.007 回答