ios/objective-c:使用 NSFRC 的 changeUpdate 和 configureCell 与 cellForRowAtIndexPath

ios/objective-c: changeUpdate and configureCell vs cellForRowAtIndexPath with NSFRC

对于 tableviewcontroller,我使用 cellforrowatindexpath 来配置单元格。

但是,当更改核心数据中的某些内容时,委托方法 controllerDidChangeObjectatObjectAtIndexPath 会触发,对于 changeUpdate,Apple 似乎要求您使用 configureCell 重写该行。

最好practice/necessary完全复制 configureCell 中 cellforRowAtIndexPath 的代码,还是有更好的方法来保持代码相同。例如,是否有一种方法可以消除一个或另一个代码块。

在 cellforrowatindexpath 和 configure cell 中必须使用相同的代码来配置单元格似乎容易出错且多余。

将公共代码放在另一个方法中,然后从 cellForRowAtIndexPathconfigureCell 调用这个新方法。或者,如果合适,只需从 cellForRowAtIndexPath 调用 configureCell

不要重复代码。将公共代码重构为一个方法,该方法可以从您可能拥有重复代码的地方调用。