iOS字符串非空判断分类写法

代码如下:

@implementation NSString (NormalMethod)

/**
 *  非空判断
 *
 *  @return 空 为 YES , 非空 NO
 */
- (BOOL)isEmpty {
    
    if (self == [NSNull null]) {
        return YES;
    }
    
    if (self == nil || self == NULL) {
        return YES;
    }
    if ([self isKindOfClass:[NSNull class]]) {
        return YES;
    }
    if ([[self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length]==0) {
        return YES;
    }
    if ([self isEqualToString:@"(null)"]) {
        return YES;
    }
    if ([self isEqualToString:@""]) {
        return YES;
    }
    if ([self isEqualToString:@"null"]) {
        return YES;
    }
    return NO;
}

你可能感兴趣的:(iOS字符串非空判断分类写法)