NSString 類(lèi)別?
集成方法為
@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