今天在构建我的应用程序时,我遇到了一个问题。我在MyObject1中声明了一个协议,并在其中添加了一个委托属性。我将MyObject2分配为MyObject1的委托。我按照通常的方式添加它,如下所示:
@interface MyObject2 : UIViewController <DelegateOfObject1>
但是Xcode说无法找到我的协议声明。我检查了代码,但我确实声明了这个协议。我尝试将MyObject2分配为其他对象的委托。
我编辑了我的代码,像这样:
@interface MyObject2 : UIViewController <UITableViewDelegate,DelegateOfObject1>
但是Xcode再次说它找不到DelegateOfObject1的协议声明。我尝试删除我的代码中的DelegateOfObject1,然后将MyObject分配为其他对象的委托,如下所示:
@interface MyObject2 : UIViewController <UITableViewDelegate,UITabBarDelegate>
没有发现任何错误。然后我再次尝试将DelegateOfObject1重新添加到代码中:
@interface MyObject2 : UIViewController <UITableViewDelegate,UITabBarDelegate,DelegateOfObject1>
那时Xcode没有发现任何错误。因此,我再次尝试从代码中删除UITableViewDelegate和UITabBarDelegate:
@interface MyObject2 : UIViewController <DelegateOfObject1>
这时没有发现任何错误,但那是我之前编写的相同代码。这种问题可能是什么原因呢?
谢谢...