Quitting and Forfeiting

A player can quit a match at any time by swiping across it from the matchmaker view controller. However, you might want to add a path for your users to forfeit or quit a match from inside of your game itself. To allow a player to forfeit a match, use the following code snippet.

- (IBAction)forfeit:(id)sender {     [self.match participantQuitOutOfTurnWithOutcome:GKTurnBasedMatchOutcomeQuit withCompletionHandler:^(NSError *error) {         if (error) {             NSLog(@"An error occurred ending match: %@", [error localizedDescription]);         }     }]; }

Get Beginning iOS Game Center and Game Kit: For iPhone, iPad, and iPod touch now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.