Reputation: 352
I am writing a code to give the string to the macro..In macro i am writing @"ready to get with:\"%@\".Find out ." How to give the above thing in macro and i need to call that macro and i need to send the string value to that perticular "%@" that is there in the macro..how to give that.....
#define MSG_STR(x)
#define DES_STR [NSString stringWithFormat:@"ready to get:\"%@\".Find out how here.", MSG_STR(x)]
NSString *shareFinalText = MSG_STR(shareWord);
I need the final string like """ready to get:shareFinalstring.Find out how here.
Upvotes: 1
Views: 230
Reputation: 86651
#define MSG_STR(x) @"" #x
will turn any x into an NSString
constant e.g.
NSLog(@"%@", MSG_STR(a + b));
will give output similar to
2011-08-25 11:00:10 +0100 otest[89432:707] a + b
It works using the fact that the compiler coalesces syntactically adjacent string constants.
Upvotes: 0
Reputation: 13310
Not totally sure I understand what you want to achieve, but could you not just use the following:
#define DES_STR(message) [NSString stringWithFormat:@"ready to get:\"%@\".Find out how here.", message];
NSString *shareFinalText = DES_STR(shareWord);
Upvotes: 2