Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
After establishing a match, it is the match delegate’s role to manage changes in the state of the match. The two primary fail states include a failed match (connection to Game Center) and a failed player connection (connection from Game Center to another player). For a failed match, you’ll want to alert the user, clean up your ongoing gameplay and revert to a pre-match “ready to play” state, as is shown in the following method:
- (void)match:(GKMatch *) aMatch didFailWithError:(NSError *)error
{
NSLog(@"Match failed: %@",
playerID, error.localizedFailureReason);
[self cleanupGUI];
// Alert the user. I include the error here because it can
// provide useful context. You may choose otherwise.
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Lost Game Center connection"
message:error.localizedFailureReason
delegate:nil cancelButtonTitle:nil
otherButtonTitles:@"Okay", nil];
[alert show];
}