Re: Protocol implementation split between base and derived class
Re: Protocol implementation split between base and derived class
- Subject: Re: Protocol implementation split between base and derived class
- From: Prachi Gauriar <email@hidden>
- Date: Thu, 9 Dec 2004 11:52:29 -0500
On Dec 8, 2004, at 7:16 PM, Scott Hancher wrote:
Can anyone comment on why XCode is throwing a compiler warning though?
This seems like an error to me.
The language in the Objective-C spec is somewhat ambiguous, but my
interpretation of it is that the compiler is correct.
@interface MyClass: MySuperClass <MyProtocol>
...
@end
implies that MyClass *adopts* MyProtocol. From the spec: "A class is
said to adopt a formal protocol if it agrees to implement the methods
the protocol declares." This leads me to believe that the class itself
has to implement the methods in the protocol, i.e. adoption cannot be
inherited.
Conforming to a protocol isn't as strong. "A class is said to conform
to a formal protocol if it (or a superclass) implements the methods
declared in the protocol."
Finally, an incorporated protocol is what you used to solve your
problem, a protocol within another protocol:
@protocol MyProtocol <MyOtherProtocol>
...
@end
A class can adopt an incorporated protocol by either "implementing the
methods the protocol declares, or inheriting from a class that adopts
the protocol and implements the methods."
See
<http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/
LanguageOverview/chapter_3_section_7.html> for more details.
-Prachi
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden