I’m attempting to rewrite a Java library over in Objective-C. I’d like to rewrite it as an API so that certain methods are required to be implemented. I’ve begun to try to rewrite the code but I’ve run into a few questions.
-
Does Objective-C support abstract classes?
-
If not, should I be writing protocols, or just use my own classes? I know that you can mark methods required.
-
If I do write protocols, Would it be okay if I group all the protocols into one header file, or is it best practice not to?
-
If I use my own classes, is there a way to require subclassing of abstract methods?
There are compiler enforced abstract classes in Objective-C, protocols are what you are after.
I would personally break the protocols out into multiple headers for legibility.