I'm creating a framework and I want to add private methods to a superclass inside a category so they are not exposed.
As an example let's say I have a public class defined as:
@interface Animal : NSObject
- (void)makeNoise;
@end
And a public subclass like:
@interface Dog : Animal
- (void)makeNoise;
@end
Now I want to add private methods related to all Animal
objects so I create a category like:
@interface Animal(PrivateMethods)
- (void)privateSing;
@end
And the problem comes here. Isn't it possible from the subclass to access the superclass PrivateMethods
category?
If I run the following code, I get a unrecognized selector sent to instace
error:
#import "Animal+PrivateMethods.h"
@implementation Dog
- (void)description {
// unrecognized selector sent to instace
[self privateSing];
}
@end