I am trying to convert my project to Swift 3.0 however I am having two error messages when working with NSNumber and Integers.
Cannot assign type int to type NSNumber
for
//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
}
and even when I change currentIndex to a type NSNumber then I get the error
Binary operator '+=' cannot be applied to type 'NSNumber' and 'Int'
so then I create a property called one of type NSNumber to add to currentIndex but then get the following error;
Binary operator '+=' cannot be applied to two NSNumber operands
&& the second error I get is
No '+' candidates produce the expected contextual result type NSNumber
let num: Int = 210
let num2: Int = item.points.intValue
item.points = num + num2
Here I am just trying to add 210 to the points property value, item is a NSManagedObject.
So basically I am having issues getting my head around adding numbers to properties of type NSNumber. I am working with NSNumber because they are properties of NSManagedObject's.
Can anyone help me out ? I have over 80 errors which are all either one of the above errors mentioned.
Thanks