iOS字符串不为空判断
2020-04-02 本文已影响0人
烟雨酱南
- (BOOL)isEmptyStr:(NSString *)string{
if ( ![string isKindOfClass:[NSString class]]) {
return YES;
}
if (string == nil || string == NULL) {
return YES;
}
if ([string isKindOfClass:[NSNull class]]) {
return YES;
}
if ([[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length]==0) {
return YES;
}
if ([string isEqualToString:@"<null>"]) {
return YES;
}
if ([string isEqualToString:@"(null)"]) {
return YES;
}
if ([[string lowercaseString] isEqualToString:@"null"]) {
return YES;
}
return NO;
}