[英]NSMutableString: Need to insert no value instead of (null)
我将字符串的值传递给 web 服务。 如果字符串有一些值,那么就可以了。
但如果不包含 null 的任何值,则打印 (null)。
例如:
NSMutableString *str1 = [NSMutableString stringWithFormat:@""];
NSString *string = [NSString stringWithFormat:@"str1 has %@ value", str1];
NSLog(@"%@", string);
应该打印:str1 有值
而是打印: str1 has (null) value
您可以使用表达式str1?: @""
来使用字符串,如果它为 nil,则可以使用空字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.