[NSNull isEqualToString:]
A cast will not change an object class
(type).
You have to manage the case when your value is [NSNull null]
with something like :
id displayNameTypeValue = [object objectForKey:@"display_name"];
NSString *displayNameType = @"";
if (displayNameTypeValue != [NSNull null])
displayNameType = (NSString *)displayNameTypeValue;
I created a category on NSNull, works well for me:
@interface NSNull (string)
-(BOOL) isEqualToString:(NSString *) compare;
@end
@implementation NSNull (string)
-(BOOL) isEqualToString:(NSString *) compare {
if ([compare isKindOfClass:[NSNull class]] || !compare) {
NSLog(@"NSNull isKindOfClass called!");
return YES;
}
return NO;
}
@end
You might want something like this:
NSString *displayNameType = NSStringFromClass([[object objectForKey:@"display_name"] class]);
And btw in your question, it shouldn't read "if it's NULL", but rather "if it's an NSNull
instance".