I'm trying to work out the line of code I need to use in order to determine if the 'destructive' button has been press in a UIActionSheet.
I've had a look around and found the delegate method...
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
.. and I've also managed to find [myActionSheet destructiveButtonIndex]
, I'm just not sure how to put the two together. This is what I have tried so far with no success:
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == destructiveButtonIndex)
{
// Do something...
}
}
You were very close with your code. The implementation you're looking for is:
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == actionSheet.destructiveButtonIndex)
{
// Do something...
}
}