Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"expected type" while implementing delegate

I am writing just a piece of code, but taking an error that "expected type @line - (void)backButtonTapped:(TopBarViewController *) topBarViewController;

What is wrong with this?

@protocol TopBarDelegate

- (void)backButtonTapped:(TopBarViewController *) topBarViewController;

@end


@interface TopBarViewController : UIViewController
{

}

@property (assign, nonatomic) id <TopBarDelegate> delegate;

-(void) backButtonPressed:(id)sender;

-(void) menuButtonPressed:(id)sender;

@end
like image 230
erdemgc Avatar asked Dec 09 '22 14:12

erdemgc


1 Answers

Add the following at the top. Since the protocol TopBarDelegate is defined above the class TopBarViewController, at the point you define the protocol, the compiler doesn't know there is a class called TopBarViewController. This line tells it there really is a class with that name defined somewhere.

@class TopBarViewController;
like image 52
Ahmed Mohammed Avatar answered Dec 11 '22 12:12

Ahmed Mohammed