Swift 3.0 - NSNumber and Int cannot be applied to operands

3.4k Views Asked by At
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

1

There are 1 best solutions below

0
On BEST ANSWER

Problem solved.

By simply adding .intValue.

var Rating = self.currentPerson.Rating

let c = Rating.intValue - 1

Cred @luk2302