Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find protocol declaration in Xcode

Tags:

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>

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>

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>

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

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

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?

Thanks...

like image 835
edie Avatar asked Apr 29 '10 12:04

edie


2 Answers

The error is caused due to import loop.

like image 160
Valla Avatar answered Oct 19 '22 10:10

Valla


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

like image 20
edie Avatar answered Oct 19 '22 11:10

edie