繁体   English   中英

创建单元格时,这是否构成了强大的参考周期?

[英]Is this making a strong reference cycle when creating cell?

我有一个Task类型的数组,它是一个类。 cellForRowAt ,创建我的单元格。 我要做的第一件事是通过使用indexPath访问数组来查看要使用的任务。 那是一个强大的参考周期的结果吗?

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let currentBudgetTask = currentBudgetTaskForRowAtIndexPath(indexPath)
    guard let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as? BudgetCell else {
        return BudgetCell()
    }

    configureCell(cell, for: currentBudgetTask)
    return cell
}

不,因为您只是将一个包含两个整数的索引路径传递给一个函数。

该指数路径并不适用于类(或细胞本身)的任何方法的引用,所以这是安全的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM