2011-08-17 32 views
1

我将字符串的值传递给Web服务。如果字符串有一些值,那么就没问题。NSMutableString:需要插入没有值而不是(空)

但如果不包含任何值为null的值,则它会打印(null)。

为如:

NSMutableString *str1 = [NSMutableString stringWithFormat:@""]; 
NSString *string = [NSString stringWithFormat:@"str1 has %@ value", str1]; 

NSLog(@"%@", string); 

应打印:STR1具有价值

,而不是它打印如:str1有(空)值

+1

它打印“STR1具有价值”对我来说,就像你所期望的。你确定问题不在其他地方吗? – Tommy

回答

4

您可以使用表达式str1 ?: @""使用的字符串,或一个空字符串,如果它是零。

+0

谢谢你jtbandes – Hanuman

相关问题