目标C>有没有办法检查Selector返回值? [英] Objective C >> Is there a way to check a Selector return value?

查看:100
本文介绍了目标C>有没有办法检查Selector返回值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个可以分配给多个不同方法的选择器 - 每个方法都有不同的返回值。

let's say I have a selector that may be assigned to several different methods - each one has a different return value.

有没有办法检查什么是在调用performSelector之前,选择器持有的方法的返回值?

Is there a way to check what is the return value of the method the selector is holding before calling "performSelector"?

推荐答案


有没有办法检查选择器持有的方法的返回值是什么在调用performSelector之前?

Is there a way to check what is the return value of the method the selector is holding before calling "performSelector"?

值?号码类型?邑。您似乎想要该方法的返回类型(或者您的问题没有意义)。

Value? No. Type? Yap. It seems that you want the return type of the method (or your question wouldn't make sense).

Method m = class_getInstanceMethod([SomeClass class], @selector(foo:bar:));
char type[128];
method_getReturnType(m, type, sizeof(type));

然后你可以检查中返回的类型字符串。例如,v表示无效(google完整列表)。

Then you can examine the returned type string in type. For example, "v" means void (google the full list).

这篇关于目标C>有没有办法检查Selector返回值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆