首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >找不到协议声明

找不到协议声明
EN

Stack Overflow用户
提问于 2011-06-23 07:04:18
回答 6查看 58.6K关注 0票数 64

我有两个view controllers AB,它们彼此都有自己的代理。

当我除了在头文件的开头定义协议和#import对方的头文件之外什么也不做时,我得到了两个关于以下内容的错误:

找不到"BDelegate“的协议声明,它显示在A.h (我写的地方)找不到"ADelegate”的协议声明,它显示在B.h (我写的地方)

在网上看一看,人们早些时候写道,头文件的循环包含可能导致了问题。他们建议使用#include,或者像这样的@class声明-

代码语言:javascript
运行
复制
@class A

而不是

代码语言:javascript
运行
复制
#import A.h

#import B.h内幕

我尝试了几乎所有这些导入的组合,以及@classes#include,但仍然无法摆脱警告。此外,在线解决方案建议将#import移动到.m文件,但这也没有帮助。部分原因是网上的解决方案有点模糊--如果你能把它分解一下,那就太好了。

有什么建议可以解决这个问题吗?

-- BigViewController.h --

代码语言:javascript
运行
复制
#import "BaseViewController.h"
#include "BaseViewController.h"

@class BigViewController;

@protocol BigViewControllerDelegate
-(void) BigViewController:(BigViewController *) bigView;
@end

@interface BigViewController : UIViewController <BaseViewControllerDelegate>
{    
     //delegate
     id <BigViewControllerDelegate> delegate;

ivars...    
}

@properties...
@end

--------------------------------------------------

-- BaseViewController.h --

代码语言:javascript
运行
复制
#<UIKit/UIKit.h>

#import "BigViewController.h"
#include "BigViewController.h"

@class BigViewController;

@protocol BaseViewControllerDelegate
- (void) setParametersWithItemChosen:(Item *) item;
@end

@interface BaseViewController : UIViewController <...BigViewControllerDelegate...>
{

   ivars...

   //delegate
    id <BaseViewControllerDelegate> delegate;
}

@properties...
@end
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6447573

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档