Reputation: 3
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
Reputation: 4177
Try pulling the participant out of the participants array first, like so:
GKTurnBasedParticipant *part0 = match.participants[0];
part0.matchOutcome = GKTurnBasedMatchOutcomeWon;
Upvotes: 1