Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: addObserver problem with protocols
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: addObserver problem with protocols




On Jan 14, 2009, at 3:18 PM, Mohan Parthasarathy wrote:

I have protocol X that is implemented by a few classes of my own. These
classes are not known directly to my main code but only through the protocol
(id<protocol>). When my main code tries to addObserver:self to the object
id<protocol>, i get a warning saying that my protocol does not implement it.
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 object
make the method just invoke the [super addobserver]. Or is there a better
way to solve it ?

If you search the archives you will find a few discussions on this subject. I don't remember the reason exactly, but you just can't use that syntax. You can use an informal protocol instead, but you won't get the compile-time checks that <protocol> gives you.


HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

_______________________________________________

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


References: 
 >addObserver problem with protocols (From: "Mohan Parthasarathy" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.