• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Xcode warns about missing protocol definition, even though @protocol is used
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Re: Xcode warns about missing protocol definition, even though @protocol is used (From: Florian Pilz <email@hidden>)

  • Prev by Date: Core Data: Setting attribute of deleted object causes it to remain in store
  • Next by Date: Re: how to prevent TableView update on key repeat?
  • Previous by thread: Re: Xcode warns about missing protocol definition, even though @protocol is used
  • Next by thread: [Sandbox]Question on Design Guide
  • Index(es):
    • Date
    • Thread