I have defined the MYMACRO macro. Note: the value is not a valid NSString.
#define MYMACRO is
Macro used inside an NSString declaration
@"This MYMACRO fun"
However, the preprocessor does not extend the macro. Pre-processed result
@"This MYMACRO fun"
The best solution I've found so far to deploy a macro:
#define MYMACRO @"is" @"This " MYMACRO@ " fun"
The macro expands as shown below, which is a valid Objective-C syntax:
@"This "@"is"@" fun"
However, execution requires 2 concatenations at runtime.
So my question is: how to insert a macro into an NSString without using any string concatenation at runtime?
Ideally, I would like runtime to execute @"This is fun" , not @"This "@"is"@" fun"
source share