FROM : Prachi Gauriar
DATE : Thu Dec 09 17:52:29 2004
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
DATE : Thu Dec 09 17:52:29 2004
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 mails | Author | Date |
|---|---|---|
| Scott Hancher | Dec 8, 23:35 | |
| Ricky Sharp | Dec 8, 23:48 | |
| Scott Hancher | Dec 9, 00:15 | |
| Christian Brunsche… | Dec 9, 00:51 | |
| Scott Hancher | Dec 9, 01:16 | |
| Prachi Gauriar | Dec 9, 17:52 | |
| Scott Hancher | Dec 9, 20:34 | |
| Marcel Weiher | Dec 11, 00:48 |






Cocoa mail archive

