I've realized there's no abstract classes in Objective-C. Is there any way to achieve the same functionality in some other way (a class that can't be instantiated, or methods that MUST be overridden by their subclass)?
Asked
Active
Viewed 698 times
0
-
Maybe a protocol would do it, with non-`optional` methods? – trojanfoe Dec 11 '15 at 07:19
1 Answers
1
It depends exactly what you want. If you would just use the class as an interface with no implementation then using a protocol instead is best. If you need some base or default implementation then you either document that the class shouldn't be instantiate do directly (common nowadays I think) or you implement the class to throw exceptions if it is instantiated directly (uncommon nowadays). Also throw exceptions in any methods that should be implemented by a subclass and are called on the superclass.
Unless you're creating a framework that will be delivered to other developers it's generally not worth the effort to implement, just document.

Wain
- 118,658
- 15
- 128
- 151
-
Alright, good answer- if you'd like the cash prize, the bounty is still open in http://www.bountyc.com/bounties/63 – maor10 Dec 11 '15 at 09:05
-