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

2018-11-21  本文已影响0人  LWide

代码如下:

@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:@"<null>"]) {
        return YES;
    }
    if ([self isEqualToString:@"null"]) {
        return YES;
    }
    return NO;
}
上一篇下一篇

猜你喜欢

热点阅读