Users Pricing

forum

Home Forums In Objective-C problem in creating view delegate – MindStick

In Objective-C problem in creating view delegate

Tarun Kumar 2194 25 Sep 2015

I have a problem with my delegate, when I was trying to create a delegate protocol in a custom UIView.

Here is my code:

@protocol MyViewDelegate

@optional

- (void) myViewDidInitialize:(MyView *)myView;

@end

 

@interface MyView : UIView {   

@private

}

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

@end

This doesn't work because the MyView interface has not been declared at the time of the MyViewDelegate declaration. I was tried to adding a prototype before the @protocol:

@interface MyView;

But this just drives the compiler nuts. How am I supposed to do this?


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md