GKTurnBasedMatchOutcome

GKTurnBasedMatchOutcome

我正在Swift中制作基于回合的iOS游戏,在调用endMatchInTurnWithMatchData方法之前,需要设置每个参与者的matchOutcome属性。但是函数中的第一行代码(下面)导致错误Cannot assign a value of type 'GKTurnBasedMatchOutcome' to a value of type 'GKTurnBasedMatchOutcome!'

func endGame()
{
    self.currentMatch.participants[0].matchOutcome = GKTurnBasedMatchOutcome.Won
    self.currentMatch.endMatchInTurnWithMatchData(gameData, completionHandler: {(error) -> Void in gameData = NSData()})
}

最佳答案

尝试首先将参与者从参与者数组中拉出,如下所示:

GKTurnBasedParticipant *part0 = match.participants[0];
part0.matchOutcome = GKTurnBasedMatchOutcomeWon;

关于swift - 无法分配GKTurnBasedMatchOutcome,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31953149/

10-12 06:19