machoota
machoota

Reputation: 289

Correct way to end GKTurnBasedMatch out of turn

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?

Upvotes: 1

Views: 896

Answers (1)

m9__
m9__

Reputation: 101

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.

Upvotes: 1

Related Questions