Boh*_*Gao 9 protocols objective-c
我首先声明了一个协议,然后使用它.但是我收到警告"无法找到LeveyPopListViewDelegate的协议定义".这是代码:
@protocol LeveyPopListViewDelegate;
@interface LeveyPopListView : UIView <LeveyPopListViewDelegate,UITableViewDataSource, UITableViewDelegate,UITextFieldDelegate>
//the content of LeveyPopListView
@end
@protocol LeveyPopListViewDelegate <NSObject>
//the definition for LeveyPopListViewDelegate
@end
Run Code Online (Sandbox Code Playgroud)
如果我首先提出定义LeveyPopListViewDelegate,我就不能LeveyPopListView在协议中使用.
我最终压制了对该特定线路的所有警告,这不是理想的但是效果很好.
// 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
Run Code Online (Sandbox Code Playgroud)
确保你进行推送和弹出,否则你最终将忽略此文件的所有警告!
我总是这样做:
@class LeveyPopListView;
@protocol LeveyPopListViewDelegate <NSObject>
//the definition for LeveyPopListViewDelegate
@end
@interface LeveyPopListView : UIView <LeveyPopListViewDelegate,UITableViewDataSource, UITableViewDelegate,UITextFieldDelegate>
//the content of LeveyPopListView
@end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9721 次 |
| 最近记录: |