As Jonathan says, you should really avoid this, if at all possible. This is just a bad design that needs this feature. If your base class is intended for a subclass, its documentation should state which methods should be overridden and which others may be overridden. Everything else should not be redefined to avoid such problems.
However, if you are in a very unusual situation when it is necessary (you may be stuck with third-party code that cannot be reorganized), this is possible. But it is ugly. You need to call objc_msgSendSuper or objc_msgSendSuper_stret manually after creating an instance of struct objc_super , pointing to self and YourBaseClass .
Note that if you use C ++, the default behavior is the same - if you call SomeFunction() from your base class and this is a virtual method, a subclass will be redefined. You will need the prefix of your call to explicitly indicate the class, for example. MyBaseClass::SomeFunction() . There is no direct equivalent for this in Objective-C - I would say because it is just such a bad idea at all.
source share