How to avoid big and clumsy UITableViewController on iOS?
Posted
by
Johan Karlsson
on Programmers
See other posts from Programmers
or by Johan Karlsson
Published on 2012-11-29T13:20:41Z
Indexed on
2013/10/21
22:03 UTC
Read the original article
Hit count: 358
I have a problem when implementing the MVC-pattern on iOS. I have searched the Internet but seems not to find any nice solution to this problem.
Many UITableViewController
implementations seems to be rather big. Most examples I have seen lets the UITableViewController
implement <UITableViewDelegate>
and <UITableViewDataSource>
. These implementations are a big reason why UITableViewController
is getting big. One solution would be to create separate classes that implements <UITableViewDelegate>
and <UITableViewDataSource>
. Of course these classes would have to have a reference to the UITableViewController
. Are there any drawbacks using this solution? In general I think you should delegate the functionality to other "Helper" classes or similar, using the delegate pattern. Are there any well established ways of solving this problem?
I do not want the model to contain too much functionality, nor the view. I believe that the logic should really be in the controller class, since this is one of the cornerstones of the MVC-pattern. But the big question is:
How should you divide the controller of a MVC-implementation into smaller manageable pieces? (Applies to MVC in iOS in this case)
There might be a general pattern for solving this, although I am specifically looking for a solution for iOS. Please give an example of a good pattern for solving this issue. Please provide an argument why your solution is awesome.
© Programmers or respective owner