工程中用到判断空值的地方有很多,每次都要判断无非是耗时耗力,定义一个全局的方法只要调用就能达到判断空值的
//空值判断
static inline BOOL IsEmptyValue(id thing) {
return thing == nil
|| ([thing respondsToSelector:@selector(length)]
&& [(NSData *)thing length] == 0)
|| ([thing respondsToSelector:@selector(count)]
&& [(NSArray *)thing count] == 0)
|| ([thing isKindOfClass:[NSNull class]]);
}