I am extending the functionality of a class from a subclass, and I am doing some dirty things that make superclass methods dangerous (the application will hang in a loop) in the context of the subclass. I know that this is not a great idea, but I am going to use low-hanging fruits, and now it will save me. Oh, it's a dirty job, but someone has to do it.
On the bottom line, I need to either block this method from the outside, or throw an exception when it is called directly in the superclass. (But I still use it from a subclass, except with caution).
What would be the best way to do this?
UPDATE ---
So this is what I went for. I do not answer my own questions, as Boaz's answer mentions several valid ways to do this, this is exactly what suits me. In a subclass, I tried the method as follows:
- (int)dangerousMethod { [NSException raise:@"Danger!" format:@"Do not call send this method directly to this subclass"]; return nil; }
I mark this as an answer, but obviously this does not mean that it is closed, further suggestions are welcome.
source share