Friday 3 April 2015

Replace Null, , (null) , nil , NSNull, Values from NSString with empty string @""



+(NSString*)replaceNullValuesWithEmptyString:(id)tempObj
{
    if (([tempObj isKindOfClass:[NSNull class]])||
        (tempObj == nil) ||
        (tempObj == (id)[NSNull null])||
        [tempObj isEqual:[NSNull null]] ||
        [tempObj isEqual:nil]) {
    }
    else {
        if([tempObj respondsToSelector:@selector(isEqualToString:)]) {
            if ([tempObj isEqualToString:@"<null>"] ||
                [tempObj isEqualToString:@"(null)"]) {
            }
            else {
                if ([tempObj respondsToSelector:@selector(length)]) {
                    if ([tempObj length]>0) {
                         NSLog(@"Check Passed.");
                        return tempObj;
                    }
                }
            }
        }
    }
    NSLog(@"Check failed.");
    return @"";

}