---
title: "In Objective-C problem in creating view delegate"  
description: "In Objective-C problem in creating view delegate"  
author: "Tarun Kumar"  
published: 2015-09-25  
updated: 2015-09-25  
canonical: https://www.mindstick.com/forum/33469/in-objective-c-problem-in-creating-view-delegate  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 1 minute  

---

# In Objective-C problem in creating view delegate

I have a [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) with my [delegate](https://www.mindstick.com/articles/777/delegate-and-event-in-c-sharp), when I was [trying](https://answers.mindstick.com/qa/93698/6-mistakes-couples-are-trying-to-save-money) to create a delegate [protocol](https://www.mindstick.com/forum/55090/what-is-stateless-protocol) in a [custom](https://www.mindstick.com/blog/12298/use-custom-writing-services-to-get-through-the-finals) UIView.

Here is my [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii):

```
@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](https://www.mindstick.com/articles/12101/interfaces-in-java-extending-interfaces) has not been declared at the time of the MyViewDelegate declaration. I was tried to adding a [prototype](https://www.mindstick.com/news/2386/every-detail-regarding-twitter-leak-of-xiaomi-outfolding-smartphone-prototype) before the @protocol:

@interface MyView;

But this just drives the [compiler](https://www.mindstick.com/articles/27/just-in-time-compiler) nuts. How am I supposed to do this?

## Replies

### Reply by Anonymous User

Here is your problems solution, I think you can forward the declared protocol:\

```
@protocol MyViewDelegate;@interface MyView: UIView{@private id<MyViewDelegate> delegate;}@property(nonatomic, assign) id<MyViewDelegate> delegate;@end@protocol MyViewDelegate@optional -(void) myViewDidInitialize:(MyView *)myView;@end
```


---

Original Source: https://www.mindstick.com/forum/33469/in-objective-c-problem-in-creating-view-delegate

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
