带有一些参数的performSelector
我想执行有几个参数的方法。有什么简单的方法可以一次性通过其中几个吗?就像
[self performSelector:@selector(methodName) withObject:firstParameter withObject:secondParameter afterDelay:0.1];
我在这里找到了一种方法 SEL PerformSelector 和参数,但似乎有点复杂,我想应该有一些更简单的方法来完成它。但对于我来说,可能只是这样,因为我是 Objective C 的新手:)
我会非常感谢你的帮助!
I want to perform the method which has a few arguments. Is there any easy way to pass a few of them at once? Something like
[self performSelector:@selector(methodName) withObject:firstParameter withObject:secondParameter afterDelay:0.1];
I've found a way here SEL performSelector and arguments, but it seems a little bit complicated and I guess there should be some easier way to make it done. But probably it just looks like that to me because of being newbie in Objective C :)
I'll appreciate your help a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
范围。
特性。将这个新创建的对象作为参数发送。
parameter.
properties. Send this newly created object as parameter.
或者另一种解决方案:
与
performSelector:
不同,方法objc_msgSend
可以采用许多不同类型的参数,例如NSObject
(和子类)或 <代码>BOOL、int
、char*
等。Or another solution:
Unlike
performSelector:
, methodobjc_msgSend
can take a lot of parameters with different types, likeNSObject
(and child classes) orBOOL
,int
,char*
etc.