Abramodj
Abramodj

Reputation: 5879

How to two strings in #define?

I'm using

#define SITO @"http://localhost:3000"
#define MISSING @"http://localhost:3000/photos/large/missing.png"

Is it possible to do this dynamically? I mean

#define SITO @"http://localhost:3000"
#define MISSING @"<<SITO>>/photos/large/missing.png"

Upvotes: 0

Views: 284

Answers (2)

Simon Lee
Simon Lee

Reputation: 22334

Use...

#define MISSING SITO @"/photos/large/missing.png"

Upvotes: 4

Jhaliya - Praveen Sharma
Jhaliya - Praveen Sharma

Reputation: 31722

You are not allowed you embed one micro within other. But you could nested as suggested by @Simon Lee.

Use the below approach.

#define SITO @"http://localhost:3000"
#define MISSING @"<<%@>>/photos/large/missing.png"

Construct a string as belwo.

NSString* Missing = [NSString stringWithFormat:MISSING,SITO];
NSLog(@"Missing %@", Missing);

Upvotes: 0

Related Questions