• 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: Compiler can't find method declared in protocol
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compiler can't find method declared in protocol


  • Subject: Re: Compiler can't find method declared in protocol
  • From: Roland King <email@hidden>
  • Date: Tue, 18 Dec 2012 22:41:43 +0800

If you move the protocol definition to the .h file does it help instead of just having the forward declaration.

I'm not seeing the problem here, but I would say that a protocol not defined in the .h but in the .m file is a bit unusual. That's the first thing I'd try.

On 18 Dec, 2012, at 10:31 PM, Jerry Krinock <email@hidden> wrote:

> I am so stumped as to why llvm cannot see the declaration of a method in a protocol that I have reproduced the issue in a small test project.  An error or warning occurs in the last line of the following code, where I send the message to a delegate which is declared to implement the protocol.
>
> If ARC is on, I get this the error:
> No visible @interface for 'NSObject<RPTokenControlDelegate>' declares the selector 'tokenControl:renameToken:'
>
> If ARC is off, it instead appears as a warning:
> Instance method '-tokenControl:renameToken:' not found (return type defaults to 'id')
>
> In my real project, which is non-ARC, if I ignore the warning, the code runs OK.
>
> Thank you for answering what must be a simple question.
>
> Jerry Krinock
> D
> *******  JunkLib.h **********************************************
>
> #import <Foundation/Foundation.h>
>
> @protocol RPTokenControlDelegate ;
>
> @interface RPTokenControl : NSObject {
>    NSObject <RPTokenControlDelegate> * m_delegate ;
> }
>
> @property (assign) NSObject <RPTokenControlDelegate> * delegate ;
>
> @end
>
>
> *******  JunkLib.m **********************************************
>
> #import "JunkLib.h"
>
> @protocol RPTokenControlDelegate
>
> - (void)tokenControl:(RPTokenControl*)
>         renameToken:(NSString*)token ;
>
> @end
>
> @implementation RPTokenControl
>
> - (IBAction)renameSelectedToken:(NSMenuItem*)sender {
>    [[self delegate] tokenControl:self
>                      renameToken:@"junk"] ;  // ERROR!!
> }
>
> @end
>
>
> _______________________________________________
>
> 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

_______________________________________________

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: 
 >Compiler can't find method declared in protocol (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Compiler can't find method declared in protocol
  • Next by Date: Re: Compiler can't find method declared in protocol
  • Previous by thread: Compiler can't find method declared in protocol
  • Next by thread: Re: Compiler can't find method declared in protocol
  • Index(es):
    • Date
    • Thread