Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find protocol definition for XXX

I have declared a protocol firstly, and then use it. But I get a warning "Cannot find protocol definition for LeveyPopListViewDelegate". Here is the code:

@protocol LeveyPopListViewDelegate;

@interface LeveyPopListView : UIView <LeveyPopListViewDelegate,UITableViewDataSource,   UITableViewDelegate,UITextFieldDelegate>

//the content of LeveyPopListView

@end

@protocol LeveyPopListViewDelegate <NSObject>
//the definition for LeveyPopListViewDelegate
@end

if I put the definition LeveyPopListViewDelegate at first, I can not use the LeveyPopListView in the protocol.

like image 461
Bohan Gao Avatar asked Feb 21 '13 01:02

Bohan Gao


2 Answers

I ended up suppressing all warnings for that particular line, which is not ideal but works well.

// Forward-declare protocols (to avoid circular inclusion)
@protocol YourProtocol;
#pragma clang diagnostic push
// To get rid of 'No protocol definition found' warnings which are not accurate
#pragma clang diagnostic ignored "-Weverything" 

@interface YourClass: NSObject
// <YourProtocol>
#pragma clang diagnostic pop

Make sure you do push & pop, otherwise you'll end up with all warnings being ignored for this file!

like image 112
Ege Akpinar Avatar answered Sep 30 '22 04:09

Ege Akpinar


If you followed the good advice in this post and still have the issue try just doing a clean. I was scratching my head over it for a while and a clean resolved the issue.

like image 37
Ryan Avatar answered Sep 30 '22 06:09

Ryan