Let's say I have a class with the following structure and I wish to override one of its delegate method (or more, in general one of its public methods), but now it is based on some private methods. Is there a way to extend it or should I simply conclude that it was not designed with extensibility in mind?
MyBaseClass.h:
@interface MyBaseClass : UIView <UITableViewDataSource, UITableViewDelegate>
{
}
// some public methods
@end
MyBaseClass.m:
@interface MyBaseClass (Private)
- (void)_privateMethod1;
- (void)_privateMethod2;
@end
#pragma mark - UITableViewDataSource
// ------ I'D LIKE TO CHANGE THE BEHAVIOR OF THIS METHOD EXTENDING MyBaseClass
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)rowIndexPath {
[self _privateMethod1];
[self _privateMethod2];
}
@end
I also need to refer to the private methods if I will actually follow through with extending the class but obviously I do not want to access to any private method. I'm sorry if the question sounds a little bit trivial.
Thanks
You can declare your private methods in a separate header MyBaseClassPrivate.h instead of in the implementation file and import that in the subclass.