+ (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;
}
参考链接: 何为代码质量?——用脑子写代码
网友评论