字符串
+ (BOOL) isBlankString:(NSString *)string {
if (string == nil || string == NULL) {
return YES;
}
if ([string isKindOfClass:[NSNull class]]) {
return YES;
}
if ([[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length]==0) {
return YES;
}
return NO;
}
数组
if (array != nil && ![array isKindOfClass:[NSNull class]] && array.count != 0)
字典
[Dict isKindOfClass:[NSNull class]] 或者 [value isEqual:[NSNull null]]
// 或者 写分类
if(![dict objectForKey:key]){
return NO;
}
id obj = [dict objectForKey:key];// judge NSNull
return ![obj isEqual:[NSNull null]];
网友评论