I got a sample code from Protected methods in Objective-C
It has one answer as below:
/////// SuperClass.h
@interface SuperClass
@end
/////// SuperClass.m
@implementation SuperClass
- (void) protectedMethod
{}
@end
/////// SubClass.h
@interface SubClass : SuperClass
@end
/////// SubClass.m
@interface SubClass (Protected)
- (void) protectedMethod ;
@end
@implementation SubClass
- (void) callerOfProtectedMethod
{
// this will not generate warning and call super's protectedMethod
[self protectedMethod];
}
@end
I tried it, and it indeed can call supler class method, working like 'protected'
My question is, why methods declared in (Protected) without implementation, but can be routed to super class's implementation? Could someone explain how it works?