+ (BOOL)notEmptyString:(NSString *)string {
if (!string) {
return NO;
}
static NSSet *emptySet;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
emptySet = [NSSet setWithObjects:@"", @"null", @"(null)", @"<null>", @"NULL", nil];
});
if ([emptySet containsObject:string]) {
return NO;
}
if ([string isKindOfClass:NSNull.class]) {
return NO;
}
//去掉空格之后長度為0
if (0 == [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]].length) {
return NO;
}
return YES;
}
參考鏈接: 何為代碼質(zhì)量咱揍?——用腦子寫代碼