Working with NSNumber & Integer values in Swift 3

Before Swift 3, many types were automatically “bridged” to an
instance of some NSObject subclass where necessary, such as String to
NSString, or Int, Float, … to NSNumber.

As of Swift 3 you have to make that conversion explicit:

var currentIndex = 0
for item in self.selectedFolder.arrayOfTasks {
   item.index = currentIndex as NSNumber // <--
   currentIndex += 1
}

Alternatively, use the option “Use scalar properties for primitive data types” when creating the NSManagedObject subclass,
then the property has some integer type instead of NSNumber,
so that you can get and set it without conversion.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)