objective-cinheritanceprivate-methods

In ObjC, how do I hide implementation a superclass's methods in a subclass?


In ObjC, how do I hide implementation a superclass's methods in a subclass?

I'm not sure if @private would do the trick, as it appears to only apply to ivars.


Solution

  • There are no actually "private" methods in Obj-C; since any message can be sent to any object at runtime, there's no way to prevent someone from sending the message you care about.

    That said, you can intercept that message in the subclass and not handle it. The simplest way to make a superclass's method inaccessible is to override it in the subclass and do nothing:

    - (void)someMethodIDontWantToSupport
    {
    }