在Xcode中找不到协议声明 [英] Cannot find protocol declaration in Xcode

查看:268
本文介绍了在Xcode中找不到协议声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天在构建应用程序时经历了一些事情. 我在MyObject1中声明了一个协议,并在其上添加了委托属性.我已将MyObject2分配为MyObject1的代表.我像往常一样以这种方式添加了

I've experienced something today while I'm building my app. I've declared a protocol in my MyObject1 and add delegate property on it. I've assign MyObject2 as a Delegate of the MyObject1. I've added it in this way as usual

@interface MyObject2 : UIViewController <DelegateOfObject1>

但是Xcode说找不到我的协议声明.我已经检查了我的代码,但已经声明了该协议.我尝试将MyObject2分配为其他Object的委托. 我已经像这样编辑我的代码

But the Xcode says that my the protocol declaration cannot be found. I've check my code but I've declared this protocol. I've try to assign MyObject2 as delegate of other Object. I've edit my code like this

@interface MyObject2 : UIViewController <UITableViewDelegate,DelegateOfObject1>

但是Xcode再说一次,它找不到DelegateOfObject1的协议声明.我试图删除我的代码上的DelegateOfObject1并添加assign MyObject作为其他对象的委托,事情就这样.

but Xcode say again that it cannot found declaration of protocol of DelegateOfObject1. I've tried to delete the DelegateOfObject1 on my code and add assign MyObject as delegate of other object and it goes like this.

@interface MyObject2 : UIViewController <UITableViewDelegate,UITabBarDelegate>

没有发现错误.然后,我再次尝试在代码中再次添加我的DelegateOfObject1

No errors have been found. Then I've tried again to add again my DelegateOfObject1 in the code

@interface MyObject2 : UIViewController <UITableViewDelegate,UITabBarDelegate,DelegateOfObject1>

那时Xcode在我的代码上没有发现任何错误.因此,我再次尝试在我的代码中删除UITableViewDelegate和UITabBarDelegate.

At that time Xcode did not find any error on my code. So I tried again to remove the UITableViewDelegate and UITabBarDelegate on my code.

@interface MyObject2 : UIViewController <DelegateOfObject1>

当时没有发现错误,但是那是我之前编写的相同代码.在我的代码中可能是什么原因造成的?

At that time No error had found but that was the same code I've write before. What should probably the cause of that stuff on my code?

谢谢...

推荐答案

我已将协议声明放在单独的文件中,并将其导入MyObject2

I've put my protocol declaration on separate file and import it on MyObject2

这篇关于在Xcode中找不到协议声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆