![](/img/trans.png)
[英]Swift sortinplace binary operator > cannot be applied to two nsnumber operands
[英]Swift 3.0 - NSNumber and Int cannot be applied to operands
var Rating = self.currentPerson.Rating
let c = Rating - 1
我试图得到self.currentPerson.Rating
的value x
并从value x
减去1。 但我只是得到了错误。
错误 :二进制运算符' - '不能应用于'NSNumber'和'Int'类型的操作数
问题 :我该如何解决这个问题?
谢谢
问题解决了。
只需添加.intValue
。
var Rating = self.currentPerson.Rating
let c = Rating.intValue - 1
Cred @ luk2302
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.