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: Jens Alfke <email@hidden>
- Date: Thu, 03 May 2012 17:22:57 -0700
On May 3, 2012, at 2:54 PM, Florian Pilz wrote:
> Hi again. I just stumbled about this problem for another time and rethought Ulis explanation. The point of my writing is: Ulis explanation is wrong. The program compiles (with a warning) and runs perfectly fine.
Well, Uli was wrong in implying that the compiler *has* to know the definition of the protocol. It can generate code without it. But he’s correct that the compiler wants to know the definition so it can do proper consistency checking.
> So basically Xcode tells me, that it must know the implementation details, which are not given in the header file (but may be added in the implementation file -- therefore a warning rather an error).
> Is there a flag to disable such a warning?
Probably, but that’s the wrong approach. Warnings are there for a reason. If you disable the warning, then if you add a new method to the protocol later but don’t update a class that implements the protocol, you may not find out until your program throws an exception at runtime.
You should instead add an #import to your header so that the actual protocol definition gets parsed before the class that implements it.
(Also, this thread belongs on xcode-users or objc-language, not cocoa-dev.)
—Jens
_______________________________________________
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