Tony Rich
Tony Rich

Reputation: 3

GKTurnBasedMatchOutcome cannot be assigned

I'm making a turn based iOS game in Swift and before the endMatchInTurnWithMatchData method is called it is required that I set the matchOutcome property of each participant. But this first line of code (below) in the function results in an error 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()})
}

Upvotes: 0

Views: 84

Answers (1)

Thunk
Thunk

Reputation: 4177

Try pulling the participant out of the participants array first, like so:

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

Upvotes: 1

Related Questions