当我使用 UITableViewControllers 时——尤其是在使用 NSFetchedResultsController 时——我发现自己在每个 Controller 上重复了很多基本功能。我讨厌。我更愿意将这些方法编写一次并保持整洁。
所以我想知道:你们怎么做才能不重复自己编写 UIViewControllers。你好吗DRY上你的代码。继承、协议(protocol)等等。
谢谢!期待您的回答。
(由于这个问题没有明确的答案,我会接受我认为最好的那个。
是这样的吗?)
最佳答案
您可以编写具有基本功能的自己的 Controller ,然后子类化并重用它们。检查为斯坦福 iPhone 应用程序开发类(class)构建的 CoreDataTableViewController 类 -> http://www.stanford.edu/class/cs193p/cgi-bin/drupal/node/167
关于iphone - 使用 UITableViewController 时如何尽量减少重复自己,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4876600/