Instance Method


Called when the player selected a match to view.


optional func turnBasedMatchmakerViewController(_ viewController: GKTurnBasedMatchmakerViewController, didFind match: GKTurnBasedMatch)



The view controller that found a match.


The match that the player selected.


This method is called when a match has been found or created. The match object is returned to your delegate. Typically, your game dismisses the matchmaker view controller and immediately starts its own user interface to allow the player to play a turn. The implementation in Listing 1 uses a custom segue to show the gameplay screen. The match is passed as the sender so that it can be passed as an input to the new view controller.

Listing 1

Implementing the match found method

- (void)turnBasedMatchmakerViewController:(GKTurnBasedMatchmakerViewController *)viewController didFindMatch:(GKTurnBasedMatch *)match
    [self dismissViewControllerAnimated:YES completion:nil];
    [self performSegueWithIdentifier:@"GamePlayScene" sender:match];
- (void )prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    if ([segue.identifier isEqualToString:@"GamePlayScene"])
        MyGamePlayViewController* gameVC = (MyGamePlayViewController*) segue.destinationViewController;
        gameVC.delegate = self;
        gameVC.match = (GKTurnBasedMatch*) sender;