0
有什麼方法可以通過stringWithFormat訪問#defines,例如: G。在一個循環內?Objective C:通過stringWithFormat訪問#define
例如:
#define text1 @"AAA"
#define text2 @"BBB"
#define text3 @"CCC"
...
,循環:
for (int i = 1; i < 10; i++) {
NSLog(@"%@",[NSString stringWithFormat:@"text%i",i]); //want to access #defines here
}
號'#define'僅用於AY編譯時,不是運行。 – rmaddy 2014-10-01 15:34:35
是否必須定義這樣的字符串?可能你可以將它們存儲在數組中嗎? – 2014-10-01 15:36:19
您以前使用過哪些語言?如果你用C/C++編程,你應該明白你不能這樣做。如果只有Java,那麼也許你可以放棄。 – 2014-10-01 15:41:35