gpt4 book ai didi

objective-c - Objective-C 中的方法签名和选择器有什么区别?

转载 作者:太空狗 更新时间:2023-10-30 03:57:41 29 4
gpt4 key购买 nike

直到现在,我相信 -(void)startToDoSomethingWithThis:(That*)thing andThat:(That*)otherThing 具有以下“方法签名”,同时也是选择器:-startToDoSomethingWithThis:andThat:

但是现在有人说选择器不像方法签名,方法签名还包含参数及其类型。对吗?

最佳答案

选择器是类中方法的名称。它用于标识方法,通常在调用方法时使用。签名是参数和返回类型的描述。在调用任意方法(例如通过 NSInvocation)时使用它来安排参数并为返回值腾出空间。许多选择器可能具有相同的签名。

SEL aSelector = @selector(method:foo:);
NSMethodSignature *aSignature = [theObject methodSignatureForSelector:aSelector];

NSMethodSignature 是 objc_method_description 类型的包装器。

关于objective-c - Objective-C 中的方法签名和选择器有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3095015/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com