user1464243
user1464243

Reputation: 43

How to resolve the "Expected a type" error in ios

Am new to development.I got an error regarding the "Expected a Type" error.In two classes of my application,i declared the method in one class and in another class i used that method with the help of @protocol method.How to resolve it.Two classes DayButton.h and DDCalenderView.h In DayButton.h, i declared as

 @protocol DayButtonDelegate <NSObject>
-(void)dayButtonPressed:(id)sender;
@end

And in DDCalenderView.h,i wrote as

@protocol DDCalenderViewDelegate<NSObject>
-(void)dayButtonPressed:(DayButton *)button;

Getting an exception near void method in DDCalenderView.h

Upvotes: 4

Views: 11970

Answers (2)

Jelle
Jelle

Reputation: 1034

In DDCalenderView.h you should type @class DayButton; above @protocol DDCalenderViewDelegate<NSObject>. This will tell the compiler that DayButton is a class (that is declared somewhere else).

You can also add #import "DayButton.h" to the top of DDCalenderView.h.

Upvotes: 2

Ratnakar
Ratnakar

Reputation: 443

SOLUTION: Move the import from the implementation to the header file. I think that there were some imports in the implementation file that were not in the header file.Make sure that you have the correct import. It’s one of those little bugs/mistakes that make you shake your head… at yourself.

Upvotes: 8

Related Questions