到目前为止,我一直认为-(void)startToDoSomethingWithThis:(That*)thing andThat:(That*)otherThing有以下“方法签名”,它同时也是选择器:-startToDoSomethingWithThis:andThat:
但是现在有人说选择器不像方法签名,方法签名也包含参数和它们的类型。对吗?
发布于 2010-06-23 00:29:33
选择器是类中方法的名称。它用于标识方法,最常见的是在被调用时。签名是对参数和返回类型的描述。它在调用任意方法时使用,例如通过NSInvocation来排列参数并为返回值腾出空间。许多选择器可能具有相同的签名。
SEL aSelector = @selector(method:foo:);
NSMethodSignature *aSignature = [theObject methodSignatureForSelector:aSelector];NSMethodSignature是objc_method_description类型的包装器。
发布于 2010-06-23 00:30:30
是这样的。选择器是方法的名称。方法签名是返回类型和参数类型的封装。您可以使用返回NSMethodSignature对象的+[NSObject instanceMethodForSelector:]来内省方法签名。
https://stackoverflow.com/questions/3095015
复制相似问题