What would be the best way to share code between two view controllers that basically show the same information? My addView is very similar to my detailView. I’ve tried using one view controller for the both of them, but that seemed to get messy and I was not able to follow the information as well.
So if I decide to use two view controllers, is it “best” or “most efficient” to just copy and paste and then change some code? I’m thinking that would work but it might not be best because if I change code in one later on, then I’d probably have to change it in the other one as well. Not terrible but it doesn’t seem like the most efficient solution.
You could solve this problem using inheritance. If View B is very similar to View A then make View B inherit from View A.
Here is an example of how to use inheritance in your class.
Inheritance – Techotopia