我在tableView中为reload Cell添加了一个按钮,我希望,当按下按钮时,删除特定单元格上的数组元素但是我收到此错误
上下文类型“Int”不能与数组文字一起使用
@IBAction func reloadCell(_ sender: UIButton) {
let index = IndexPath(row: sender.tag, section: 0)
sortedArray.remove(at: [index]) //HERE I GET THE ERROR
self.tableView.reloadRows(at: [index], with: .right)
}
我怎么解决呢?
数组使用Int
s作为索引,而不是像IndexPath
那样使用tableView
s:
sortedArray.remove(at: sender.tag)
您不能对数组使用IndexPath类型(您应该使用int类型)ex:
sortedArray.remove(at: index.row)
self.tableView.reloadRows(at: index.row, with: .right)