swift 3 gamecenter: number of participants are alw

2019-06-23 23:40发布

I made a TurnBased game that was working perfectly with swift 2. I could successfully change the code to swift 3.2 and correct all the errors about 400, but there is one issue with the game centre that I can not figure out how to fix it. When through gamecenter viewcontroler I set the number of the participant to “2Player” and then push “Invite Friends” the number of Player that I get is 4 instead of 2! the gamecenter send a text message to the next participant in which the number of participant is 4 too. This of course affect the rest of the program a problem that I didn’t have in Swift 2. This is part of my code:

func joinTurnBasedMatch()
{
    let request = GKMatchRequest()
    request.minPlayers = 2
    request.maxPlayers = 4
    request.defaultNumberOfPlayers = 2

    let tbvc = GKTurnBasedMatchmakerViewController(matchRequest: request)
    tbvc.turnBasedMatchmakerDelegate = self
    present(tbvc, animated: true, completion: nil)
}

func turnBasedMatchmakerViewController(_ viewController: GKTurnBasedMatchmakerViewController, didFind match: GKTurnBasedMatch)
{
    self.dismiss(animated: true, completion: nil)
    self.performSegue(withIdentifier: "To_ViewC_CG", sender: match)
    print("*** Number OF Players ***")
    print(match.participants!.count)
}  

Do I need to add anything to my code or change anything in it?

1条回答
甜甜的少女心
2楼-- · 2019-06-24 00:07

The problem has been solved in the latest ios update. Now it works perfectly.

查看更多
登录 后发表回答