iOS -轉載-字串是否為空判斷方法
阿新 • • 發佈:2018-12-03
- (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; }