创建了一个可变数组,往数组里面插入相关节点的时候indexpath
报错信息为:cannot convert value of type 'NSMutalbeArray' to expected argument type '[IndexPath]'
//获取需要修正的indexpath
let indexPathArray = NSMutableArray()
for i in startPosition...endPosition {
let tempIndexPath:NSIndexPath = NSIndexPath(row: i, section: 0)
indexPathArray.add(tempIndexPath)
}
//插入或者删除相关节点
if expand {
self.insertRows(at: indexPathArray, with: UITableViewRowAnimation.none)
}
insertRows(at: _, with: _) This method, the first parameter is a
[IndexPath]
Since you use swift, it is recommended to use the swift data type
This
NSMutableArray is an objc class, two things that are completely incompatible with struct[IndexPath]
也就是Array<IndexPath>
Array 的定义是 swift 中的一个
struct
is alsoArray<IndexPath>
The definition of Array is a
struct
in swiftAlso, in Swift 3, the NS prefix is removed, don’t use
NSIndexPath
,而是用IndexPath
.