【发布时间】:2016-01-17 13:46:21
【问题描述】:
问题出在我的项目中。但我也在新的 xcode 草案项目中尝试了 Master-Detail Application 之一。
我已经创建了基本 Cell 类并将单元映射到情节提要上。删除操作后 deinit 从未调用过。对单元格的引用没有强弱之分。
class Cell:UITableViewCell {
deinit{
print("Deinit Called")
}
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! Cell
let object = objects[indexPath.row] as! NSDate
cell.textLabel!.text = object.description
return cell
}
【问题讨论】:
-
我猜原因是table view cell被重用了,所以它们实际上并没有被删除,实际上只是回到了cell pool。
-
在取消初始化表格视图之前,您的单元格不会被取消初始化,那是因为表格视图持有它的强引用
标签: swift uitableview memory-management deinit