超过2个对象的performSelector [英] performSelector with more than 2 objects

查看:81
本文介绍了超过2个对象的performSelector的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以调用[anObject performSelector];有两个以上的物体?我知道您可以使用数组来传递多个参数,但是我想知道是否存在一种较低层的方法来调用已经定义了2个以上参数的函数,而不使用带有nsarray参数的辅助函数.

Is there a way to call [anObject performSelector]; with more than 2 objects? I know you can use an array to pass multiple arguments, but I was wondering if there was a lower level way to call a function I already have defined with more that 2 arguments without using a helper function with an nsarray of arguments.

推荐答案

任一(1)使用

Either (1) Use an NSInvocation or (2) directly use objc_msgSend.

objc_msgSend(target, @selector(action:::), arg1, arg2, arg3);

(注意:确保所有参数都是id的,否则参数可能无法正确发送.)

(Note: make sure all arguments are id's, otherwise the arguments might not be sent correctly.)

这篇关于超过2个对象的performSelector的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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