(Cocoa) Can I Subclass and Delegate at the same time?
Posted
by Alvin
on Stack Overflow
See other posts from Stack Overflow
or by Alvin
Published on 2010-05-11T17:57:00Z
Indexed on
2010/05/11
18:04 UTC
Read the original article
Hit count: 219
@interface ClassB <ClassADelegate> : ClassA
id <ClassBDelegate> delegate;
@end
As the code says, ClassB subclasses from ClassA and handles the formation protocol of Class A. However, the variable "delegate" will be duplicated. (ClassA also has "delegate")
In fact, it can be done without subclassing, but it seems the code is cumbersome, i.e., to use a variable/function of ClassA, I need to write [[ClassB classA] doSomething] instead of [classB doSomething], where doSomething: is a function of ClassA.
Are there any tidy way for me to do that?
© Stack Overflow or respective owner