[NSPlaceholderString initWithString:]:

一、参数为空的bug

nil argument- 参数为空导致!
一个错误,坑我太久啊!!!
伤不起!原来是传参数A,A参数为空!!!
一定要谨慎啊!做参数判断!!!
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSPlaceholderString initWithString:]: nil argument'
*** First throw call stack:
(0x35a5788f 0x37dfe259 0x35a57789 0x35a577ab 0x354ff4c9 0x39756f 0x398137 0x39b5a3 0x354e6a81 0x3557a591 0x32e1a735 0x32e1a5f0)
terminate called throwing an exceptionterminate called throwing an exception(lldb)

二、容错处理

// 对字符串做特殊的宏,即保证返回的值不为空
#define ISNIL(x) ((x) == nil ? @"" : (x))
#define ISNILDefault(x, y) ((x) == nil ? y : (x))
#define ISNULL(x) ((x) == nil || [(x) isEqualToString:@"NULL"] || [(x) isEqualToString:@"null"] ? @"" : (x))

你可能感兴趣的:([NSPlaceholderString initWithString:]:)