到现在为止,我相信它-(void)startToDoSomethingWithThis:(That*)thing andThat:(That*)otherThing有以下"方法签名",同时也是选择器:-startToDoSomethingWithThis:andThat:
但现在有人说选择器不像方法签名,方法签名也包含参数及其类型.那是对的吗?
选择器是类中方法的名称.它用于识别方法,最常见的是在调用方法时.签名是参数和返回类型的描述.它在调用任意方法时使用,例如通过NSInvocation来安排参数并为返回值腾出空间.许多选择器可能具有相同的签名.
SEL aSelector = @selector(method:foo:);
NSMethodSignature *aSignature = [theObject methodSignatureForSelector:aSelector];
Run Code Online (Sandbox Code Playgroud)
NSMethodSignature是objc_method_description类型的包装器.
那是对的.选择器是方法名称.方法签名是返回类型和参数类型的封装.您可以使用+[NSObject instanceMethodForSelector:]返回NSMethodSignature对象的方法签名内省.