I'm particularly interested in how to follow Apple's standards with respect to a good MVC pattern design. Let me illustrate my question with an example.
Lets say I have a number of fairly complicated UI elements on screen such as UITableView
. Basically these elements require a datasource and a delegate to handle interaction.
There are two approaches to working with this.
I can have the same subclass of UITableViewController
handling all of the elements and dynamically handling things based on the requesting UITableView
.
Second approach would be to have "lightweight" controllers that would manage each individual view. In iOS 4.x you're not allowed to have multiple UIViewControllers, so these controllers would be more for managing state and interaction.
I don't like the first approach because it doesn't scale and seems to combine things. What if I have multiple complex objects of dissimilar type?
The second approach seems better. Objects are encapsulated better - separation of concerns. The only downside seems to be increased complexity of communication. Lightweight controllers would have to either delegate back to the real view controllers or they'd have to have a handle to something to perform real actions.
What is your experience with either of these approaches? Is there a better solution for decomposing a complicated interface?
Thanks