如何调用具有可变数量参数的实现? [英] How to call an implementation with variable number of arguments?
本文介绍了如何调用具有可变数量参数的实现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为了简化,假设我有一个这样的函数
To simplify, let's say I have a function like that
void myFunc(id _self, SEL _cmd, id first, ...)
{
}
在那个方法中,我想调用 _self 超类的实现(imp).我可以使用此代码访问该 IMP:
In that method I wanna call the implementation(imp) on the superclass of _self. I can reach that IMP with this code:
Class class = object_getClass(_self);
Class superclass = class_getSuperClass(class);
IMP superimp = class_getMethodImplementation(superclass, _cmd);
现在,我该怎么称呼那个小鬼?
now, how can I do to call that imp ?
推荐答案
只需使用可变参数调用即可:
Just call it using variable arguments:
superImp(self, _cmd, argument1, argument2, argument3, etc...)
IMP 已经 typedef
'd as
IMP is already typedef
'd as
typedef id (*IMP)(id, SEL, ...);
因此您可以毫无问题地使用可变参数调用它.
So you can call it with variable arguments with no issue.
这篇关于如何调用具有可变数量参数的实现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文