We’ve all been there. UIViewController implementation. A massive viewDidLoad implementation. Methods that also do similar things to viewDidLoad once data from a webservice changes. This sort of thing.
I’m gonna keep this post short and sweet. I made a sort of template UIViewController implementation that you should take a look at over on my github page here.
I felt inclined to write this because there are design patterns in iOS development that involve Apple’s best practices, but Apple’s best practices avoid getting too off topic; Their best practices for UIViewControllers focus a lot on the View and Controller, but iOS is typically a MODEL-View-Controller paradigm.
So, I created a template for how I write my UIViewController subclasses (In general… every project is different). But let’s assume you have a principal data model your view controller is managing. This data model may have a collection of objects associated with it that is used for a table/collection view.
The pattern I came up with below I think does a pretty good job of keeping the models to themselves, and the views to themselves, and knows when the view needs to refresh itself based on the state of the model.
Check it out. Would appreciate some feedback!