swift 3 gamecenter: number of participants are always 4

╄→гoц情女王★ 提交于 2019-12-12 11:35:17

问题


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:


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



来源:https://stackoverflow.com/questions/41915243/swift-3-gamecenter-number-of-participants-are-always-4

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!