1. 程式人生 > >iOS -轉載-字串是否為空判斷方法

iOS -轉載-字串是否為空判斷方法

- (BOOL)blankString{
    if (![self isKindOfClass:[NSString class]] ){
        return  YES;
    }
    if ([self isEqual:[NSNull null]]){
        return  YES;
    }
    if (self == NULL || [self isEqual:nil] || [self isEqual:Nil] || self == nil){
        return  YES;
    }
    if([self isEqualToString:@"
(null)"]){ return YES; } if([self isEqualToString:@"<null>"]){ return YES; } if (self.length == 0 || [[self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length] == 0){ return YES; } return NO; }