一次向多个对象发送消息(objective-c) [英] send message to multiple objects at once (objective-c)

查看:104
本文介绍了一次向多个对象发送消息(objective-c)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(或设置多个具有一个值的对象)
有没有办法在一行中发送一个消息的多个对象。

(or set multiple objects with one value) Is there a way to send multiple objects one message in one line.

所以喜欢

[someObject, otherObject reset];

就像LUA脚本(我相信是C?)你可以设置多个对象:

like in LUA scripts (which I believe is C?) you can set mutliple objects:

someThing, otherThing = 1 , 0


推荐答案

简而言之,不,Objective-C和C都不支持此功能。作为极端措施,您可以使用 - [NSArray makeObjectsPerformSelector:] - [NSArray makeObjectsPerformSelector:withObject:] ,例如

In short, no, neither Objective-C nor C support this feature. As an extreme measure, you can use -[NSArray makeObjectsPerformSelector:] and -[NSArray makeObjectsPerformSelector:withObject:], such as

[[NSArray arrayWithObjects:someObject, otherObject, nil] makeObjectsPerformSelector:@selector(reset)];

这篇关于一次向多个对象发送消息(objective-c)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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