Why is the sender of the UIMenuItem action always zero?

I added an instance of UIMenuItem to the UIMenuController . When I double-click on a text field, I get this text editing menu using "Copy", "Cut", "Paste", "Search" on Wikipedia.

This is my action method:

 - (void)lookupInWikipedia:(id)sender { NSLog(%@"lookupInWikipedia: sender=%@", sender); } 

I get NSLog when I select the Wikipedia Search menu item. But the sender is always zero.

Even the -canPerformAction:withSender: method gets nothing but nil for the sender.

 - (BOOL)canPerformAction:(SEL)action withSender:(id)sender { NSLog(@"canPerformAction:withSender: = %@", sender); return YES; } 

Am I doing something wrong or is this a knowledge base error?

+2
source share
1 answer

I also stumbled upon this one day. Looks like a mistake.

+1
source

Source: https://habr.com/ru/post/905306/


All Articles