0

I have two classes. Both these classes are delegates of each other. This gives me error like "Can not find protocol declaration". After searching on net, I came to the conclusion that, this is the case of cyclic dependency.

To break this dependency the solution they have suggested is to define protocol in another header file. I could not find any tutorial on how to do this and how will it affect my code?

3
  • can u display the code which you have written to make delegates for each other,so that i can edit your code according to your requirement Commented Jul 21, 2011 at 9:46
  • usually we write as @class b rather than #import class b... Commented Jul 21, 2011 at 9:47
  • Kindly Display what you have tried so far.. Commented May 14, 2012 at 10:46

3 Answers 3

2

I have a example for you..

@class ClassA;
@class ClassAController;

@protocol CreateClassADelegate
-(void)CreateClassA:(ClassAController *)sender didCreateClassA:(ClassA *)ClassAObj;
-(void)CreateClassACancel:(TSInputController *)sender;
@end
Sign up to request clarification or add additional context in comments.

Comments

0

Check @Toro's answer in this previous SO question UIViewController calling each other's delegate

Comments

0

In case you are using XCode 4 you just creating new file as always, the difference is that you need to choose Objective-C protocol in Cocoa Touch section rather then Objective-C class or UIViewController subclass.
Other approach you may use is to create new Objective-C class and then just delete the .m file manualy and change @interface to @protocol in .h file.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.