<分区>
当我从 tableView 中删除一行时发生崩溃。不确定发生了什么。这是我的代码:
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
let items = days[indexPath.row]
self.removeItems(items, indexPath: indexPath)
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return days.count
}
移除元素
func removeItems(items: [CKRecord], indexPath: NSIndexPath) {
for item in items {
db.deleteRecordWithID(item.recordID) { (record, error) -> Void in
if error != nil {
println(error.localizedDescription)
}
dispatch_async(dispatch_get_main_queue()) { () -> Void in
if let index = find(exercises, item) {
exercises.removeAtIndex(index)
}
}
}
}
days.removeAtIndex(indexPath.row)
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)
}