NSString 类别
集成方法为
@interface NSString (Empty)
+ (BOOL)isEmpty:(NSString *)string;
@end
@implementation NSString (Empty)
+ (BOOL)isEmpty:(NSString *)string{
if ([[string class] isSubclassOfClass:[NSNull class]]) { return YES; } if (string == nil || string == NULL || [string isEqualToString:@"(null)"] || [string isEqualToString:@"null"] ||[string isEqualToString:@""]) {
return YES;
}
if ([string isKindOfClass:[NSNull class]]) {
return YES;
}
if ([string isKindOfClass:[NSString class]] && [[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length]==0) {
return YES;
}
return NO;
}
@end
网友评论