为什么我们在 Swift 中使用自定义单元格的 prepareForReuse 时使用 super.prepareForReuse
Why we use super.prepareForReuse when using prepareForReuse of Custom cell in Swift
因为我已经阅读了 document of Apple and 我理解了为什么我们使用 prepareForReuse 方法。
但是我不明白为什么我们要添加 super.prepareForReuse() 到 prepareForReuse()。
我想这是关于Swift的非常基础的知识,所以我努力google。但我无法理解这一点。请帮我。谢谢。
简单的回答:因为 Apple 这么说。文档说:
If you override this method, you must be sure to invoke the superclass implementation
即调用super
。去做就对了。显然 UITableViewCell class 本身 在其 prepareForReuse
的实现中做了一些事情,Apple 告诉你确保它能够做到这一点。
这就是关于此事的全部内容,因为 Cocoa 是封闭源代码。您看不到 UITableViewCell 的作用。你不应该在乎。照苹果告诉你的去做。这就是Cocoa框架的使用方法。
因为我已经阅读了 document of Apple and
但是我不明白为什么我们要添加 super.prepareForReuse() 到 prepareForReuse()。
我想这是关于Swift的非常基础的知识,所以我努力google。但我无法理解这一点。请帮我。谢谢。
简单的回答:因为 Apple 这么说。文档说:
If you override this method, you must be sure to invoke the superclass implementation
即调用super
。去做就对了。显然 UITableViewCell class 本身 在其 prepareForReuse
的实现中做了一些事情,Apple 告诉你确保它能够做到这一点。
这就是关于此事的全部内容,因为 Cocoa 是封闭源代码。您看不到 UITableViewCell 的作用。你不应该在乎。照苹果告诉你的去做。这就是Cocoa框架的使用方法。