Re: Xcode warns about missing protocol definition, even though @protocol is used
Re: Xcode warns about missing protocol definition, even though @protocol is used
- Subject: Re: Xcode warns about missing protocol definition, even though @protocol is used
- From: Kyle Sluder <email@hidden>
- Date: Thu, 03 May 2012 15:13:17 -0700
On May 3, 2012, at 3:08 PM, Marco S Hyman wrote:
>> I just tried this, and it gives me a warning:
>
> That is what he's complaining about... the warning.
Except he just said he got it to compile without a warning, which means that whatever he's got going on is more complicated than the situation as Uli and I have understood it.
>
> To the OP: there is no way a compiler can tell if a class conforms
> to a protocol when the only thing it knows is the name of the
> protocol. Thus the warning. Maybe it will compile and run...
> maybe not.
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.
But even that's not good enough, because it would make it impossible to implement a proxy class that claims to conform to a protocol but actually forwards the messages to the object it's proxying via -forwardingTargetForSelector:, without getting warnings that the class hasn't implemented the protocol methods.
--Kyle Sluder
_______________________________________________
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