0

I'm trying to learn Objective-C from a book, and ran into the following errors while trying to work through an exercise in Xcode (arrow indicates place of issue).

#import <UIKit/UIKit.h>
#import "FlashCard.h"
#import "CreateCardViewController.h"

--> @interface FlashCardsViewController : UIViewController <CreateCardDelegate> {

The above code results in the error: "Cannot find protocol declaration for 'CreateCardDelegate'. But I am importing "CreateCardViewController.h" where I have declared: @property (nonatomic, assign) id cardDelegate; so don't know what the issue is...

Having browsed a few post I suspect it may it be due to a circular #import dependency? but if that is the case then I'm not sure how to rectify this error. If you have any suggestions then please explain and do keep in mind that I am new to objective-c.

3
  • can you please post more code, so that I can explain? Please show the implementation of CreateCardViewController.h Commented Jul 24, 2012 at 16:16
  • Do you have @protocole CreateCardDelegate in CreateCardViewController.h? Commented Jul 24, 2012 at 16:17
  • This doesn't seem to be about circular dependencies, but if you want to know how to avoid them in the future read stackoverflow.com/a/7428777/412916 Commented Jul 24, 2012 at 16:30

2 Answers 2

2

You are not defining correctly

@protocol CreateCardDelegate
  ....
@end

in your CreateCardViewController.h file. Please review that definition and post the relevant code for more help.

Sign up to request clarification or add additional context in comments.

Comments

1

You need to declare the CreateCardDelegate protocol somewhere. Here's an example of a protocol declaration (in a .h file).

@protocol MyClassDelegate <NSObject>

- (void)myClass:(MyClass *)myClass someEventOccured:(NSInteger)value;
- (void)myClass:(MyClass *)myClass someOtherEventOccured:(NSInteger)value;

@end

In your case you need to have a @protocol CreateCardDelegate somewhere in those header files and import it into your .m file. Do you?

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.