Reputation: 33080
#define mySynthesize(op) @synthesize op = _op;
So rather than typing
@synthesize someVar=_someVar;
@synthesize otherVar=_otherVar;
I can just do
mySynthesize (someVar);
Well, it doesn't work though. What did I do wrong?
Upvotes: 2
Views: 124
Reputation: 39905
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
Upvotes: 10