判断对象
是否为空
+ (BOOL)isBlankObject:(__kindof id)object {
if (!object) {
return YES;
}
if (object == NULL) {
return YES;
}
if ([object isEqual:[NSNull null]]) {
return YES;
}
if ([object respondsToSelector:@selector(length)]) {
NSUInteger count = (NSUInteger)[object performSelector:@selector(length)];
return count == 0;
}
///集合类型
if ([object respondsToSelector:@selector(count)]) {
NSUInteger count = (NSUInteger)[object performSelector:@selector(count)];
return count == 0;
}
return NO;
}
网友评论