Victor
Victor

Reputation: 1623

Swift 3.0 - NSNumber and Int cannot be applied to operands

var Rating = self.currentPerson.Rating

let c = Rating - 1

Im trying to get the value x of self.currentPerson.Rating and subtract 1 from value x. But Im only getting the error bellow.

Error : Binary operator '-' cannot be applied to operands of type 'NSNumber' and 'Int'

Question : How do I solve this?

Thanks

Upvotes: 4

Views: 3449

Answers (1)

Victor
Victor

Reputation: 1623

Problem solved.

By simply adding .intValue.

var Rating = self.currentPerson.Rating

let c = Rating.intValue - 1

Cred @luk2302

Upvotes: 6

Related Questions