On Jan 14, 2009, at 2:18 PM, Mohan Parthasarathy wrote:
I have protocol X that is implemented by a few classes of my own.
classes are not known directly to my main code but only through the
(id<protocol>). When my main code tries to addObserver:self to the
id<protocol>, i get a warning saying that my protocol does not
This would have worked if i used the real object behind. What should
i do ?
Just add a method like addObserver in the protocol and in the real
make the method just invoke the [super addobserver]. Or is there a
way to solve it ?
1. Use `NSObject<MyProtocol>*` instead of `id<MyProtocol>`. Then any
method from class NSObject is allowed along with the protocol's own
methods. Since addObserver: is declared as a class on NSObject, this
should pacify the compiler.
2. Add -addObserver: to the protocol.
3. Create another protocol that includes -addObserver:. Then either
use `id<MyProtocol,MyObserverProtocol>`, or make MyProtocol itself
#1 is probably the best, assuming all of your objects are in fact
Greg Parker email@hidden Runtime Wrangler
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden