Tuesday, May 28, 2013

How to Check Null or Empty in given String

+ (BOOL)isNullOrEmpty:(NSString *)string
{
    if (string == nil)  {
        return YES;
    }
    if ((![string isKindOfClass:[NSNumber class]]) && (![string isKindOfClass:[NSString class]]) && (![string isKindOfClass:[NSDictionary class]]) && (![string isKindOfClass:[NSArray class]])) {
        return YES;
    }
   
    if (([string isKindOfClass:[NSString class]]) && ([string isEqualToString:@""])){
        return YES;
    }
   
    return NO;
}

1 comment:

Add your comment