12 Feb 2013, 16:08
Generic-user-small

dkonst (1 post)

Hello!

I have two similar TableViews which have different appearances like tableView headers,footers, etc but they share same UITableViewDataSource, hence the NSFetchedResultsControllerDelegate, by semantics. Currently I have copy pasted the shared code.

But I have no idea how to properly reuse that common UITableViewDataSource / NSFetchedResultsControllerDelegate code. The NSFetchedResultsControllerDelegate is making use of the tableView and so it requires a (strong?) reference to the tableView.

Could anyone give me a hint how could I resolve my code duplications.

Thanks in advance

13 Feb 2013, 18:29
Avatarsmall_pragsmall

Marcus S. Zarra (254 posts)

You could create a new @NSObject@ instance that implements the @UITableViewDataSource@ and @NSFetchedResultsControllerDelegate@ protocols. Then each @UITableViewController@ could instantiate its own instance of that object and thereby reuse the code.

  You must be logged in to comment