Skip navigation.
 
mlRe: Protocol implementation split between base and derived class
FROM : Scott Hancher
DATE : Thu Dec 09 20:34:37 2004

This line

"A class is said to conform to a formal protocol if it (or a 
superclass) implements the methods declared in the protocol."

seems quite unambiguous.

I suppose you could argue that

"A class is said to adopt a formal protocol if it agrees to implement 
the methods the protocol declares."

means that the class and not its inherited classes must implement the 
protocol methods, but that seems like a tenuous argument at best. When 
calling a method on an object of a particular type, it's irrelevant 
where that method is implemented in the object's inheritance chain; it 
only matters that a class in the inheritance chain implements the 
method.

I would argue that this is an error in the compiler, or at the very 
least an error in the documentation.

Thanks for the response,
++Scott.

On Thursday, December 9, 2004, at 08:52  AM, Prachi Gauriar wrote:

>
> 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

Related mailsAuthorDate
mlProtocol implementation split between base and derived class Scott Hancher Dec 8, 23:35
mlRe: Protocol implementation split between base and derived class Ricky Sharp Dec 8, 23:48
mlRe: Protocol implementation split between base and derived class Scott Hancher Dec 9, 00:15
mlRe: Protocol implementation split between base and derived class Christian Brunsche… Dec 9, 00:51
mlRe: Protocol implementation split between base and derived class Scott Hancher Dec 9, 01:16
mlRe: Protocol implementation split between base and derived class Prachi Gauriar Dec 9, 17:52
mlRe: Protocol implementation split between base and derived class Scott Hancher Dec 9, 20:34
mlRe: Protocol implementation split between base and derived class Marcel Weiher Dec 11, 00:48