开发者

What is wrong with this Macro?

#define mySynthesize(op) @synthesize op = _op;

So rather than typing

@synthesize someVar=_someVar;
@synthesize otherVar=_otherVar;

I can just do

mySynthesize (someVar);

Well开发者_Python百科, it doesn't work though. What did I do wrong?


When you prefix the op with an underscore, the preprocessor treats it as a different token, so it doesn't get replaced. You need to use ## to concatenate the underscore to the front so that the replacement occurs first.

#define mySynthesize(op) @synthesize op = _ ## op
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜