How to use GKTurnBasedMatchmaker?

Hi all,


I'm very new to iOS development. GKTurnBasedMatchmaking makes no sense to me, and I'm having a real hard time figuring out based off the docs.


Here's what I'm currently doing:

  1. Authenticate the player
  2. Make my GameScene a GKTurnBasedMatchmakingViewControllerDelegate
  3. Present the GKTurnBasedMatchmakingViewController like so:
    func makeMatch(){
        if(!gcEnabled){ return; }
       
        self.match.minPlayers = 2;
        self.match.maxPlayers = 2;
        self.match.defaultNumberOfPlayers = 2;
   
       
        let mmVC = GKTurnBasedMatchmakerViewController(matchRequest: match);
        mmVC.turnBasedMatchmakerDelegate = self;
        self.view?.window?.rootViewController?.present(mmVC, animated: true, completion: nil);
    }


I have no idea what to do after that. My intuition was that there'd be some kind of 'didFindMatch' callback to execute once a match has filled in all the players, but that appears to be deprecated.


How do I know when Game Center has found all the required auto-match players?
How come GKTurnBasedMatchmakerViewController seems to always create a new match? Shouldn't it join an existing matchmaker request if there is one?

Replies

My memory of this is awfully rusty, I think you need to be also working with GKMatchRequest. The "callback" would be a delegate method, like didFindMatch (though apparently that is now deprecated).


Have you watched the WWDC videos about this? They were very helpful, back 5 years ago when I was working on turn-based matches.