---
title: "Creating our own optional methods in protocol"  
description: "Creating our own optional methods in protocol"  
author: "Anonymous User"  
published: 2015-10-30  
updated: 2015-10-30  
canonical: https://www.mindstick.com/forum/33548/creating-our-own-optional-methods-in-protocol  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 1 minute  

---

# Creating our own optional methods in protocol

I have [notice](https://yourviews.mindstick.com/story/4562/happy-independence-day-2024-things-to-notice) that optional methods in several [protocols](https://www.mindstick.com/blog/303746/explained-the-working-of-email-an-invisible-process) are defined in the [iPhone SDK](https://www.mindstick.com/forum/34236/what-is-iphone-sdk), such as the UIActionSheetDelegate [protocol](https://www.mindstick.com/forum/55090/what-is-stateless-protocol).\
So my [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) is that can I [define](https://yourviews.mindstick.com/audio/1110/lifestyles-choices-that-define-our-lives) a protocol of my own, and set a few of the [methods as](https://www.mindstick.com/articles/12625/the-effectiveness-of-technology-based-teaching-methods-as-compared-to-traditional-approaches) optional?

## Replies

### Reply by Tarun Kumar

When we create a Protocol then we need to mark ['@optional'](mailto:) keyword, because it is responsible to create our own optional method.\
Corresponding to the ['@optional'](mailto:) keyword, here is another keyword @required, used when we want any method necessary in our code, using @optional and @required keywords we can do partition in protocol into sections and by the way by default keyword is @required in any protocol.

```
@protocol ProtocolSample - (void)defaultRequiredMethod;@optional  - (void)optionalMethod1;  - (void)optionalMethod2;@required  - (void)requiredMethod;@end
```


---

Original Source: https://www.mindstick.com/forum/33548/creating-our-own-optional-methods-in-protocol

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
