我正在尝试将我的项目转换为SWIFT 3.0,但是在使用NSNumber
和Integers
...
不能将int类型分配给nsnumber类型
为
//item is a NSManaged object with a property called index of type NSNumber
var currentIndex = 0
for item in self.selectedObject.arrayOfItems {
item.index = currentIndex
currentIndex += 1
}
即使我改变了currentIndex
到某一类型NSNumber
然后我得到错误
Binary operator '+=' cannot be applied to type 'NSNumber' and 'Int'
所以我创建了一个名为one
类型NSNumber
添加到currentIndex
然后得到以下错误;
Binary operator '+=' cannot be applied to two NSNumber operands
&&我得到的第二个错误是
No '+' candidates produce the expected contextual result type NSNumber
let num: Int = 210
let num2: Int = item.points.intValue
item.points = num + num2
这里我只是想把210加到PointProperty,item
是NSManagedObject
...
所以基本上,我有问题,让我的头脑在添加数字类型的属性。NSNumber
.我在工作NSNumber
因为它们是NSManagedObject
他的。
相似问题