I am trying to plan how to add a couple methods to all instances of certain objects. I think adding a category to the parent object(UIViewController) would work for what I want to do, but can I override a method added this way? Most of the time the subclasses will use the default methods but I do know I will need to override the method at least once.
Also what other methods should I consider for what I am trying to do?
Example of what I am trying to do:
I have a set of Objects that act like pages of a journal. These pages are subclasses of UIViewControllers. I want to add methods for loading, saving, and similar. In a journal class(Subclass of NSObject) I have an array storing instances of each Journal page. I want it so I can select a page from the array and run on of the methods without having to know the specific object class as they all should have the methods.
Short answer: yes, you can. For purposes of inheritance category methods on a superclass are treated like methods that are actually defined in the superclass, and can be overridden in the same way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With