如何获得方法的精髓? [英] How to get the arity of a method?
本文介绍了如何获得方法的精髓?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,在Javascript中,您可以通过func.length
来获得Arity(函数应采用的参数数量).如何在Objective-C中获取有关此方法的信息?
In Javascript, for example, you can get the arity (the number of arguments a function is supposed to take) by simply func.length
. How can I get this information for a method in Objective-C?
推荐答案
NSMethodSignature
is awesome for all kind of reflection information.
SEL selector = @selector(foo:);
NSMethodSignature *sig = [someObj methodSignatureForSelector:selector]
int argCount = [sig numberOfArguments];
这篇关于如何获得方法的精髓?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文