0
如何更改下面的关闭,使cell
为'弱'? :如何在Swift guard语句中定义一个弱变量
guard let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath as IndexPath) as? PlayerTableViewCell else {
fatalError("The dequeued cell is not an instance of PlayerTableViewCell")
}
我相信有一个简单的方法来实现这一点,但我一直无法确定正确的方式来处理这个。
感谢
为什么你需要在你的'cellForRowAt'方法中对单元的弱引用? – rmaddy
这只是一个'guard'声明,而不是一个关闭表达式。 – Hamish
@maddy - 我运行了检查工具,发现这个语句没有从内存中释放'cell'对象,'cell'的许多实例都在内存中。我的研究表明我需要使细胞变弱,以便在使用后从内存释放。 – Dave