2011-06-17 98 views
0

我使用如何在#define中使用兩個字符串?

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

是否可以動態地做到這一點?我的意思是

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

回答

4

使用...

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

你不允許你在其他內嵌入一個微。但你可以像@Simon Lee建議的那樣嵌套。

使用下面的方法。

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

構建一個字符串作爲belwo。

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

其實你可以嵌套定義爲每個我的答案。 :) – 2011-06-17 10:36:52

+0

@Simon李:謝謝 – Jhaliya 2011-06-17 10:38:11

相關問題