iOS 字串是否為空判斷方法
阿新 • • 發佈:2018-11-01
可以寫個分類來處理
- (BOOL)blankString{
if (![self isKindOfClass:[NSString class]] ){
return YES;
}
if ([self isEqual:[NSNull null]]){
return YES;
}
if (self == NULL || [self isEqual:nil] || [self isEqual:Nil] || self == nil){
return YES;
}
if([self isEqualToString:@"(null)"]){
return YES;
}
if([self isEqualToString:@"<null>"]){
return YES;
}
if (self.length == 0 || [[self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length] == 0){
return YES;
}
return NO;
}