objective-c - 找不到协议(protocol)声明,但我实际上正在导入它

标签 objective-c ios

我得到一个错误:找不到“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/

相关文章:

ios - 搜索属性列表时如何检测错误?

iphone - 检查 modalViewController 的动画是否完成

iphone - AVCaptureSession设置Low、Medium、High,分别代表什么res?

ios - id <SampleProtocolDelegate> 委托(delegate)与 id <SampleProtocolDelegate> _delegate

objective-c - NSTimer 问题

ios - 如何声明 iOS 应用程序共享扩展以接受来自 native 联系人应用程序的联系人

ios - 在 Phonegap 中读取用户的音乐库

ios - Web 请求确实无法正常工作

Objective-C 从文本文件创建对象

objective-c - Objective-C 中的 Sharepoint 365 ACS OAuth : realm error - Help Needed