Swift 3.0-NSNumber和Int无法应用于操作数

Vic*_*tor 4 nsnumber ios swift

var Rating = self.currentPerson.Rating

let c = Rating - 1
Run Code Online (Sandbox Code Playgroud)

我试着去获得value xself.currentPerson.Rating和减去1 value x。但是我只得到错误提示。

错误:二进制运算符“-”不能应用于类型为“ NSNumber”和“ Int”的操作数

问题:我该如何解决?

谢谢

Vic*_*tor 5

问题解决了。

通过简单地添加.intValue

var Rating = self.currentPerson.Rating

let c = Rating.intValue - 1
Run Code Online (Sandbox Code Playgroud)

Cred @ luk2302