On May 3, 2012, at 15:13 , Kyle Sluder wrote:

> Except the compiler produces the warning on the @interface, which provides no 
> information about whether the class actually implements the required protocol 
> methods. You don't need to redeclare methods from protocols you adopt. The 
> logical place to emit this warning is on the @implementation, so the compiler 
> can alert you that it can't verify you've _implemented_ all the methods you 
> claim to.

As an aside, the second kind of information that the compiler needs is the 
inheritance chain for the protocol.

The idea that the actual protocol declaration (as opposed to the forward 
reference) belongs with the implementation ignores the fact that the public 
@interface is all that clients of the class have to go on, and clients of the 
class typically need to know what methods form part of the protocol (and need 
to know the inheritance chain).

If syntax permitted that the class @interface declared conformance only, 
clients would still need to include the actual protocol declaration from 
somewhere.

In the special case of a delegate protocol, most clients of the class won't 
need to know even that the class implements the protocol, but in general the 
class @interface requires a complete protocol declaration for the benefit of 
clients.

Incidentally, I only just discovered that you can declare conformance on a 
class extension:

        @interface MyClass () <SomeProtocol>

while means there is a technique of privatizing the protocol conformance within 
the .m file, when conformance is an implementation detail of the class.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to