Sometimes it happens to me to observe my code and to say: “no, these things should be made differently”. Then I go into “refactoring”. I think this is an important step of every programmer. Don’t be afraid to refactor (don’t listen to the voice inside you: “… don’t touch that code! Nothing will work correctly after changing this single byte …”): code is something always in evolution (and in test …).
Seeing the code of Part 2 I don’t like two different callbacks to be passed to the start method:
Design Patterns are something we should use not just because they exists, but because they help us to solve a real problem we are trying to fix. The problem I wanted to solve some times ago was the strong coupling of two view controllers when they want to communicate via a segue.
The UITableView is a class we all have used at least once in our apps.
Sometimes we need a UITableView with cells all equal in height, but sometimes we need dynamic height cells, each one having a different height, typically dependent on its own content.
The old way
Before iOS8, this was not trivial since the system needed to know in advance the overall height of the table in order to set the content size of the scrolling area (UITableView inherits from UIScrollView).