我正在将字符串的值传递给Web服务。如果字符串具有某些值,则可以。
但如果不包含任何为null的值,则将打印(null)。
例如:
NSMutableString *str1 = [NSMutableString stringWithFormat:@""];
NSString *string = [NSString stringWithFormat:@"str1 has %@ value", str1];
NSLog(@"%@", string);
应该打印:str1有值
而是打印:str1的值为(null)
最佳答案
您可以使用表达式str1 ?: @""
来使用字符串,如果为nil,则可以使用空字符串。
关于iphone - NSMutableString:需要插入任何值而不是(null),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7099339/