有没有办法让预处理器宏插入参数而无需在其两侧添加空格?
长话短说,我正在尝试这样做:
#define MY_MACRO(x) id myObjectx;
创建 myObject1
和 myObject2
等等。我有很多这样的东西,真实的情况比仅仅声明对象要复杂一点,就是这样,我需要它用这个数字重复一些不同的事情,复制粘贴变得很难看。
注意:我知道根据我提供给您的信息,您可能会建议我只使用数组,所以我将解释一下 - 我需要一堆单独的 KVO 属性,并且它们不能全部放在一个数组中一对多,因为更改通知的数量会失控。
To make a somewhat long story short, I'm trying to do this:
#define MY_MACRO(x) id myObjectx;
to create myObject1
and myObject2
and so on. I have a lot of these, and the real situation is a little more complicated than just declaring the object and that's it, I need it to repeat a few different things with that number, and copy-paste is getting ugly.
Note: I understand that with the information I've given you you'll be tempted to suggest I just use an array, so I'll explain - I need a bunch of separate KVO properties, and they can't all go in a to-many because the amount of change notifications would get out of hand.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如 bmargulies 所说,您可以在宏中使用
##
:bmargulies,为什么不添加您的评论作为答案......?
As bmargulies said, you can use
##
in the macro:bmargulies, why don't you add your comment as an answer...?