【问题标题】:Deleting table view row throws a Thread 1: signal SIGABRT删除表视图行会引发线程 1:信号 SIGABRT
【发布时间】:2014-06-13 18:42:06
【问题描述】:

当我尝试使用下面的代码从表视图中删除一行时,我不断收到Thread 1: signal SIGABRT 错误。我正在使用 Swift(不知道该怎么做)并且正在构建一个基于表格视图的应用程序。我一整天都在尝试删除一行,但我却一无所获。这应该是简单的任务,但 Swift 让我无法做到。

// Override to support editing the table view.
override func tableView(tableView: UITableView?, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath?) {
    if editingStyle == .Delete {
        if let tv = tableView {
            if let ip = indexPath {
                tv.deleteRowsAtIndexPaths([ip], withRowAnimation: UITableViewRowAnimation.Fade)
            }
        }
        // Delete the row from the data source
    } else if editingStyle == .Insert {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }    
}

错误似乎与AppDelegate文件有关:

【问题讨论】:

  • 控制台告诉你什么?
  • @jsksma2 我不明白它告诉我的一半内容,但以 libc++abi.dylib: terminating with uncaught exception of type NSException 这行结尾
  • 对,NSException 通常包含一条消息。尝试运行足够深的终止,使其吐出消息。

标签: ios xcode uitableview swift


【解决方案1】:

您是否也在更新支持表格视图的数据源?如果tableView(numberOfRowsInSection) 方法不更改其返回值,则可能会导致问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-05-29
    • 1970-01-01
    • 1970-01-01
    • 2018-11-05
    • 1970-01-01
    相关资源
    最近更新 更多