gpt4 book ai didi

ios - 删除表格 View 中包含数组数据的行

转载 作者:行者123 更新时间:2023-11-29 01:04:29 25 4
gpt4 key购买 nike

如何删除数组中的行及其数据?

我使用 ordered 来保存从以前的 Controller 获取的项目。

var ordered = [ItemList:Int]();

override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == UITableViewCellEditingStyle.Delete {
ordered.removeAtIndex(indexPath.row)
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Automatic)
}
}

显示错误信息

Cannot convert value of type "Int" to expected arguement type DictionaryIndex ItemList, Int

关于 ordered.removeAtIndex(indexPath.row)

最佳答案

Dictionary 提供removeValueForKey() 相对于arrayremoveAtIndex()。所以可能你必须使用

ordered.removeValueForKey(yourKey)

您必须在其中使用 indexPath.row 找到相应的键,这需要一个数组来跟踪这些键,或者您只需将 dictionary 替换为 array

关于ios - 删除表格 View 中包含数组数据的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36568146/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com