无法分配GKTurnBasedMatchOutcome

时间:2015-08-11 22:33:49

标签: swift game-center

我在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()})
}

1 个答案:

答案 0 :(得分:1)

首先尝试将参与者拉出参与者阵列,如下所示:

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