I am trying to decide on a design pattern. I have an app where the user adds an entry to a Core Data database. They also should have the ability to edit that entry at a later time as well. Both views basically show the same data, only one is for editing what has already been added.
I am not sure if I should have two very similar separate view controllers or if I should use some kind of inheritance to set this up, or if there is some other idea that I’m not thinking of.
I appreciate your input.
I have encountered a similar item to solve and ended up going with the using the same
UIViewControllerto do both operations. Both use cases are fundamentally the same: a user enters information and then saves. The validation of the data is the same, saving is the same, the presentation is the same. They only vary on whether your model object already exists or not. Consider the following example:.h file:
.m file:
The sole purpose of this view controller is to create presentation for editing and saving model object data.