• 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: Florian Pilz <email@hidden>
  • Date: Thu, 03 May 2012 23:54:05 +0200

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. 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?

Best wishes
Florian


Am Montag, 16 April 2012 um 23:28 schrieb Uli Kusterer:

> On 16.04.2012, at 23:03, Florian Pilz wrote:
> > The import is done in the ".m"-file of HomeTableViewController. But I just found a fault in my sample code anyways: the ".h"-file of HomeTableViewController should have an "@protocol NewFooController" declaration.
> >
> > Corrected sample code for HomeTableViewController.h:
> >
> > #import <UIKit/UIKit.h>
> > @protocol NewFooControllerDelegate;
> > // warning points to line below
> > @interface HomeTableViewController : UITableViewController <NewFooControllerDelegate>
> > @end
> >
>
>
>
> That won't work. When you declare a class as conforming to a protocol, the compiler has to know what methods that protocol contains, so it can make sure to complain if one of the required methods is missing.
>
> @protocol Foo only works if you want to declare a variable of type id<Foo> (but not actually send messages to it). It simply tells the compiler "this protocol exists", but not what methods it actually consists of.
>
> It's the same as with plain C struct Foo; and struct Foo { int x; int y; }; Only the latter can actually be used (because now the compiler knows that there is a struct named 'Foo'), but you can declare pointers to the former, because for a pointer it only has to know the size of an address, not the size of the struct at that address.
>
> Cheers,
> -- Uli Kusterer
> "The Witnesses of TeachText are everywhere..."
> http://www.masters-of-the-void.com
>
>


_______________________________________________

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

  • Follow-Ups:
    • Re: Xcode warns about missing protocol definition, even though @protocol is used
      • From: Jens Alfke <email@hidden>
    • Re: Xcode warns about missing protocol definition, even though @protocol is used
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: how to prevent TableView update on key repeat?
  • Next by Date: Re: Xcode warns about missing protocol definition, even though @protocol is used
  • Previous by thread: Re: how to prevent TableView update on key repeat?
  • Next by thread: Re: Xcode warns about missing protocol definition, even though @protocol is used
  • Index(es):
    • Date
    • Thread