Search code examples
objective-cprotocols

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.


Solution

  • I always do it this way:

    @class LeveyPopListView;
    
    @protocol LeveyPopListViewDelegate <NSObject>
    //the definition for LeveyPopListViewDelegate
    @end
    
    @interface LeveyPopListView : UIView <LeveyPopListViewDelegate,UITableViewDataSource,   UITableViewDelegate,UITextFieldDelegate>
    
    //the content of LeveyPopListView
    
    @end