0

I have multiple protocol in Xcode Project it will give error such like this. help me Error Like :-> Cannot find Protocol declaration for 'ButtonDelegate' did you mean 'CustomDelegate'? Thanks in AdvanceImage

Delegate Header File

#import <UIKit/UIKit.h>
#import "Constant.h"

@protocol ButtonDelegate <NSObject>
-(void)ChatButtonClicked;
@end

@interface DonttreadonmeCell : UITableViewCell<UIGestureRecognizerDelegate,UITextViewDelegate>{

id <ButtonDelegate> Buttondelegate;

 .h File

#import <UIKit/UIKit.h>
#import <Twitter/Twitter.h>
#import "JSONParsing.h"
#import "Facebook.h"
#import "DonttreadonmeCell.h"
#import "Constant.h"



 @class DonttreadonmeCell;

    @interface BookTextPeregraphselectedViewController :   UIViewController<MFMailComposeViewControllerDelegate,FBSessionDelegate,FBRequestDelegate,ButtonDelegate,FBLoginDialogDelegate,FBDialogDelegate,JSONParsingDelegate,UITableViewDataSource,UITableViewDelegate,UIGestureRecognizerDelegate,UITextViewDelegate>{
Jignesh B
  • 490
  • 7
  • 18
  • I can't read that. Post text. –  Sep 21 '13 at 05:19
  • 1
    @H2CO3 error : Cannot find Protocol declaration for 'ButtonDelegate' did you mean 'CustomDelegate' – Jignesh B Sep 21 '13 at 05:21
  • Have you imported .h file where protocol is declared ? – βhargavḯ Sep 21 '13 at 05:23
  • @Bhargavi yes i imported .h file properly i checked twice – Jignesh B Sep 21 '13 at 05:24
  • did you create protocol for both classes like class a protocol for class b and class b protocol for class a like this? – KDeogharkar Sep 21 '13 at 05:25
  • @BaZinga both protocol has its own class for use. – Jignesh B Sep 21 '13 at 05:31
  • if you are trying to give protocol in 2 way communication for class dont do that cause compiler will confuse which protocol I have to call first. you can declare protocol in one class and use in other class or classes. – KDeogharkar Sep 21 '13 at 05:33
  • @BaZinga i little bit down there is no declaration for Protocol Y class in this class still showing me – Jignesh B Sep 21 '13 at 05:37
  • 1
    Read [How do I create delegates in Objective-C?](http://stackoverflow.com/a/626946/1280373) i think you did very simple mistake. – Nitin Gohel Sep 21 '13 at 05:55
  • Please edit your post to show the whole top of this file, so we can see all the imports and everything inside the list of protocols. Also show the file where you create the protocol. – rdelmar Sep 21 '13 at 05:56
  • @NitinGohel thanks Bro.. its silly mistake i solved my self. just declare protocol in top of the import file... it's worked i working for solve this problem since 1 day – Jignesh B Sep 21 '13 at 06:38

3 Answers3

5

I declared my protocol declaration section in top of the import file... it worked thank God.

  @protocol ButtonDelegate <NSObject>
-(void)ChatButtonClicked;
@end


#import <UIKit/UIKit.h>
#import "Constant.h"

Like this

Jignesh B
  • 490
  • 7
  • 18
1

Include header file related to particular missing protocol. In my case it was MFMailComposeViewControllerDelegate. I added

#import <MessageUI/MessageUI.h>

Problem fixed.

Mann
  • 5,477
  • 6
  • 45
  • 57
0

These 2 imports solved my problem. Please try it.

#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMailComposeViewController.h>
iPhoneDeveloper
  • 958
  • 1
  • 14
  • 23