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
精彩评论