美文网首页
iOS空值判断

iOS空值判断

作者: 今年27 | 来源:发表于2020-10-10 15:54 被阅读0次
    + (NSString *)pal_excludeNil:(NSString *)str{
        
        if ([str isKindOfClass:[NSString class]]) {
            if (str !=nil &&
                ![str isEqualToString:@"(null)"] &&
                ![str isEqualToString:@""] &&
                ![str isEqualToString:@"<null>"]){
                return str;
            }else{
                return @"";
            }
        }else if([str isKindOfClass:[NSNumber class]]){
            return [NSString stringWithFormat:@"%@",str];
        }else{
            return @"";
        }
    }
    
    + (BOOL)isValidOfDictionary:(NSDictionary *)dictionary
    {
        if (!dictionary || [dictionary isKindOfClass:[NSNull class]] || ![dictionary isKindOfClass:[NSDictionary class]] || dictionary.count <= 0) {
            return NO;
        };
        return YES;
    }
    

    相关文章

      网友评论

          本文标题:iOS空值判断

          本文链接:https://www.haomeiwen.com/subject/dptpuktx.html