[英]Find method signature for selectors in Objective-C
Where can I find the method signature for callback methods in built-in classes like UIGestureRecognizer or UIMenuItem etc? 在哪里可以在内置类(如UIGestureRecognizer或UIMenuItem等)中找到回调方法的方法签名?
eg, documentation states for UIMenuItem : 例如, UIMenuItem的文档状态:
initWithTitle:action:
initWithTitle:动作:
Creates and returns a menu-item object initialized with the given title and action.创建并返回使用给定标题和操作初始化的菜单项对象。
-(id)initWithTitle:(NSString )title action:(SEL)action
-(id)initWithTitle:(NSString )标题动作:(SEL)动作
Parameters
参数
title标题
The title of the menu item.菜单项的标题。
action行动
A selector identifying the method of the responder object to invoke for handling the command represented by the menu item.一个选择器,用于标识响应者对象的方法,以调用该对象来处理菜单项所代表的命令。
Return Value返回值
An initialized UIMenuItem object, or nil if there was a problem creating the object.初始化的UIMenuItem对象;如果创建对象有问题,则返回nil。
How do I know what parameter 'action' may receive? 我怎么知道“ action”会收到什么参数?
See the documentation for the Target-Action Mechanism in UIKit . 请参阅UIKit中的Target-Action机制的文档。 Specifically it mentions the following:
具体来说,它提到以下内容:
In contrast with the Application Kit, where an action method may have only one or perhaps two valid signatures, the UIKit framework allows three different forms of action selector:
与Application Kit(一种操作方法可能只有一个或两个有效签名)相比,UIKit框架允许三种不同形式的操作选择器:
- (void)action
- (void)action:(id)sender
- (void)action:(id)sender forEvent:(UIEvent *)event
'action' is a convention in Cocoa Touch/UIKit : Target-Action in UIKit “动作”是Cocoa Touch / UIKit中的约定:UIKit中的Target-Action
Actions can have any of the following three signatures in UIKit: 动作可以在UIKit中具有以下三个签名中的任何一个:
- (void)action
- (void)action:(id)sender
- (void)action:(id)sender forEvent:(UIEvent *)event
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.