I want to declare a method in a BaseObject, and this method only implemented by the SubObject, how can I do that? I found @protected is permitted to be used on method.
One way around this is to create a private header file containing a private interface category, like this:
//MyClass.h
@interface MyClass : NSObject
- (void)publicMethod;
@end
//MyClass_private.h
@interface MyClass ()
- (void)protectedMethod;
@end
MyClass.m and it's subclasses import the regular and _private headers, giving the _private declarations the same scope as protected. Customers of the hierarchy use only the regular headers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With