【发布时间】:2014-08-11 14:30:33
【问题描述】:
使用 Swift:我已将 NSFetchedResultsController 连接到 UITableView,并为 TableView 单元格创建了 UITableViewCells 的子类。
UITableViewCells 的格式和显示正确。但是,一旦我尝试编辑行(添加或删除),应用程序就会崩溃。
为了测试,我使用了最基本的子类:一个空的子类,它仍然崩溃。原来的 UITableViewCell 工作正常。
有什么想法吗?迅捷错误?崩溃直接进入堆栈顶部。我在控制台中什么也没有。
作品:
override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell? {
var cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
let task = fetchedResultController.objectAtIndexPath(indexPath) as Tasks
cell.textLabel.text = task.desc
return cell
}
不起作用:
override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell? {
var cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell2
let task = fetchedResultController.objectAtIndexPath(indexPath) as Tasks
cell.textLabel.text = task.desc
return cell
}
当子类是:
import UIKit
class UITableViewCell2: UITableViewCell {
}
【问题讨论】:
标签: uitableview swift