---
title: "How to identify UIActionSheet button in Objective-C?"  
description: "How to identify UIActionSheet button in Objective-C?"  
author: "Anonymous User"  
published: 2016-02-09  
updated: 2016-02-09  
canonical: https://www.mindstick.com/forum/33967/how-to-identify-uiactionsheet-button-in-objective-c  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 1 minute  

---

# How to identify UIActionSheet button in Objective-C?

I have created an **UIActionSheet** using below [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) in our [iPhone application](https://www.mindstick.com/forum/23139/can-i-embed-a-custom-font-in-an-iphone-application):

```
UIActionSheet *actionSheet = [[UIActionSheet alloc]                               initWithTitle:@"ActionSheetSample"                               delegate:self                               cancelButtonTitle:@"Cancel"                               destructiveButtonTitle:nil                               otherButtonTitles:@"Button1",@"Button2",@"Button3", nil];[actionSheet showInView:self.view];
```

[Now](https://yourviews.mindstick.com/view/81402/it-s-liberals-vs-progressives-in-us-politics-now), my [action](https://www.mindstick.com/forum/155752/what-is-action-result-with-its-types) sheet created successfully but my [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) is how can I [identify](https://www.mindstick.com/forum/159425/java-app-crash-arrayindexoutofboundsexception-identify-invalid-index) which [button is clicked](https://www.mindstick.com/forum/157821/write-a-jquery-code-that-selects-all-the-checkboxes-in-a-form-when-a-select-all-button-is-clicked).!\
Please help me!

## Replies

### Reply by Tarun Kumar

UIActionSheet provides a delegate method ***actionSheet:clickedButtonAtIndex:*** when the user clicks a [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) on an action sheet.\
For Example:

```
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{  if(buttonIndex == 0)  {     NSLog(@"First Button is Clicked");  }  else if(buttonIndex == 1)  {     NSLog(@"Second Button is Clicked");  }}
```

Above method have two parameters *actionSheet* and *buttonIndex*.\
actionsheet: contains the action button, and\
buttonIndex have the button indices which will start at 0.


---

Original Source: https://www.mindstick.com/forum/33967/how-to-identify-uiactionsheet-button-in-objective-c

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
