I am assigning protocols in a couple classes that follow an inheritance tree. Like so:
first class
@protocol LevelOne
- (void) functionA
@end
@interface BaseClass : NSObject <LevelOne> {
}
second class
@protocol LevelTwo <LevelOne>
- (void) functionB
@end
@interface SubClass : BaseClass <LevelTwo> {
}
Later I am assigning the class as delegate properties of other classes
base class
@interface AppClass : NSObject {
@protected
id<LevelOne> levelOneDelegate;
}
@property (assign) id<LevelOne> levelOneDelegate;
subclass
@interface AppClassesFriend : AppClass {
@protected
id<LevelTwo> levelTwoDelegate;
}
@property (assign) id<LevelTwo> levelTwoDelegate;
At the end of this journey, AppClassesFriend has 2 properties on it.
"levelOneDelegate" has access to "functionA", when it is assigned with a BaseClass object.
However, I am finding that "levelTwoDelegate" only has access to "functionB" (it is assigned with a SubClass object).
In order to have AppClassesFriend be able to use both functions, it seems I need to assign BOTH a levelOneDelegate AND levelTwoDelegate.
Is there any way to make "levelTwoDelegate" have access to both? Since, both functions are available on "SubClass".
So, what I would like to be able to do is :
SubClass *s = [SubClass alloc];
AppClassesFriend *a = [AppClassesFriend alloc];
a.levelTwoDelegate = s;
so inside AppClassesFriend (a) I could use :
[self.levelTwoDelegate functionA]; <---- this is never found
[self.levelTwoDelegate functionB];
but it seems I have to add
a.levelOneDelegate = s;
Thanks if anyone took the time to read all the way down this far. So in summary the question is, how do I get "levelTwoDelegate" to have access to both functionA and functionB?