Working with NSNumber & Integer values in Swift 3

前端 未结 5 1555
星月不相逢
星月不相逢 2021-01-03 17:54

I am trying to convert my project to Swift 3.0 however I am having two error messages when working with NSNumber and Integers.

5条回答
  •  -上瘾入骨i
    2021-01-03 18:27

    You should stay with or original code and just change the assignment, so that it works:

    var currentIndex = 0
    for item in self.selectedFolder.arrayOfTasks {
        item.index = NSNumber(integer: currentIndex)
        currentIndex += 1
    }
    

    As your code works fine in Swift 2, I'd expect that this is behaviour that might change in the next update.

提交回复
热议问题