当我向左滑动以删除单元格时,应用程序崩溃

时间:2016-06-24 19:58:11

标签: ios swift

当我每次向左滑动以删除我的应用程序崩溃时运行我的应用程序时它指向线程1:信号 # When the Random object's seed is different, multiple runs result in different outcome: pry(main)> [1,2,3,4,5,6,7].shuffle(random: Random.new) => [5, 6, 3, 4, 1, 7, 2] pry(main)> [1,2,3,4,5,6,7].shuffle(random: Random.new) => [1, 7, 6, 4, 5, 3, 2] # When the Random object is created with the same seed, multiple runs return the same result: pry(main)> [1,2,3,4,5,6,7].shuffle(random: Random.new(1)) => [7, 3, 2, 1, 5, 4, 6] pry(main)> [1,2,3,4,5,6,7].shuffle(random: Random.new(1)) => [7, 3, 2, 1, 5, 4, 6] “我相信这是我的代码的一部分这是造成它的。

SIGABRT

1 个答案:

答案 0 :(得分:0)

您可以像这样修改代码:

override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
    if editingStyle == .Delete {
        allItems[indexPath.section].removeAtIndex(indexPath.row)
        tableView.reloadData()
    } else if editingStyle == .Insert {
        let newData = DataItem(title: "New Data", subtitle: "", imageName: nil)
        allItems[indexPath.section].append(newData)
        tableView.reloadData()
    }
}