---
title: "How to create view delegate in iOS"  
description: "How to create view delegate in iOS"  
author: "Anonymous User"  
published: 2015-12-16  
updated: 2015-12-17  
canonical: https://www.mindstick.com/forum/33747/how-to-create-view-delegate-in-ios  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 1 minute  

---

# How to create view delegate in iOS

I have create a [delegate](https://www.mindstick.com/articles/777/delegate-and-event-in-c-sharp) in our [custom](https://www.mindstick.com/blog/12298/use-custom-writing-services-to-get-through-the-finals) UIView, here is the [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii):

```
@protocol CustomViewDelegate@optional- (void) CustomViewDidInitialize:(CustomView *)customView;@end @interface CustomView : UIView {    @private}@property(nonatomic, assign) id<CustomViewDelegate> delegate;@end
```

The above code is not working because the CustomView [interface](https://www.mindstick.com/articles/12101/interfaces-in-java-extending-interfaces) has not been declared at the time of the CustomViewDelegate declaration.\
So, now I tried it by adding a [prototype](https://www.mindstick.com/news/2386/every-detail-regarding-twitter-leak-of-xiaomi-outfolding-smartphone-prototype) ala [C++](https://www.mindstick.com/blog/745/array-in-c-plus-plus) before the @[protocol](https://www.mindstick.com/forum/55090/what-is-stateless-protocol) like this:

```
@interface FunView;
```

But it's also not solving my [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic), so [anyone](https://www.mindstick.com/articles/23207/how-to-find-the-best-fit-job-for-anyone) have the solution then [please tell me](https://www.mindstick.com/forum/33900/please-tell-me-what-are-the-technique-to-content-optimization), thank you.

## Replies

### Reply by Tarun Kumar

To forward declared protocols do like this:

```
@protocol CustomViewDelegate;@interface CustomView : UIView {    @private    id<CustomViewDelegate> delegate;}@property(nonatomic, assign) id<CustomViewDelegate> delegate;@end
```

```
@protocol CustomViewDelegate@optional- (void) customViewDidInitialize:(CustomView *)customView;@end
```


---

Original Source: https://www.mindstick.com/forum/33747/how-to-create-view-delegate-in-ios

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
