我得到一个错误:找不到“SentencesDelegate”的协议(protocol)声明。 但是,我正在导入定义协议(protocol)的 header 。 这些是 2 个头文件(分别定义和使用协议(protocol)):
SentencesViewController.h
#import <UIKit/UIKit.h>
#import "SansnuageAppDelegate.h"
// Define a new protocol
// Best practice - make this protocol conform to the <NSObject> protocol
@protocol SentencesDelegate <NSObject>
// By default, methods are "required"; you can change this by prefacing methods with "@optional"
- (void) setSentence:(NSString *)sentence;
@end
@interface SentencesViewController : UITableViewController
{
SansnuageAppDelegate* appDelegate;
NSArray *sentencesList;
}
@property (nonatomic, assign) id <SentencesDelegate> delegate;
@end
ComposerViewController.h
#import <UIKit/UIKit.h>
#import "SentencesViewController.h"
#import "ANColorPicker.h"
#import "SansnuageAppDelegate.h"
@interface ComposerViewController : UIViewController <SentencesDelegate, ANColorPickerDelegate, UITableViewDelegate, UITableViewDataSource>
{
ANColorPicker * picker;
UIView * colorView;
UITableView * composerTableView;
NSMutableArray *dataList;
SansnuageAppDelegate* appDelegate;
}
@property(nonatomic, retain) UIView * colorView;
@property(nonatomic, retain) IBOutlet UITableView *composerTableView;
@property(nonatomic, retain) IBOutlet UIButton *previewB;
@property(nonatomic, retain) IBOutlet UIButton *sendB;
@end
谢谢
最佳答案
好的,解决方案是导入#import "SentencesViewController.h" 在实现文件中也是如此。非常愚蠢的错误,但错误描述根本没有帮助。
关于objective-c - 找不到协议(protocol)声明,但我实际上正在导入它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7148800/