判断字符串

/**
 *
 *  判断空字符串
 *
 */
+(NSString*)convertNull:(id)object{
    // 转换空串
    if ([object isEqual:[NSNull null]]) {
        return @"";
    }
    else if ([object isKindOfClass:[NSNull class]])
    {
        return @"";
    }
    else if (object==nil){
        return @"";
    }
    else if ([object isKindOfClass:[NSNumber class]])
    {
        return ((NSNumber *)object).stringValue;
    }
    else if ([object isEqualToString:@"(null)"] || [object isEqualToString:@""] || [object isEqualToString:@"null"]){
        return @"";
    }
    return object;
}
/**
 *
 *  判断字符串对象是否有值
 *
 */
- (BOOL)hasValue {
    if (![self isKindOfClass:[NSString class]]) {
        return NO;
    }
    if ([self isEqualToString:@""] || [self isEqualToString:@"(null)"] || [self isEqualToString:@""]|| [self isEqualToString:@"null"]) {
        return NO;
    }
    if ([[self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length]==0) {
        return NO;
    }
    return YES;
}

你可能感兴趣的:(判断字符串)