Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if sender is UIBarButtonItem

Can anyone tell me the correct way to check if sender was a UIBarButtonItem or not. NSLog gives me these depending on what sender is:

sender for segue = <UIBarButtonItem: 0x6845e70>

sender for segue = <NSIndexPath 0x687fd00> 2 indexes [0, 0]

What command is used in an if statement to check for UIBarButtonItem?

Thanks

like image 966
Darren Avatar asked Dec 17 '22 06:12

Darren


2 Answers

if([sender isKindOfClass:[UIBarButtonItem class]])

should do it for ya

like image 196
Jesse Naugher Avatar answered Dec 27 '22 14:12

Jesse Naugher


Check this awnser: How do I test which class an object is in Objective-C?.

You could log the sender's class.

NSLog(@"Sender is a %@",NSStringFromClass([sender class]));
like image 34
thijsai Avatar answered Dec 27 '22 14:12

thijsai