Reputation: 86
I want to figure out how to do this
NSData *xxx = [xxx objectForKey:@"xxx"];
if (xxx == @"xxx")
//do somthing
Upvotes: 0
Views: 168
Reputation: 6505
Or you may just use isEqual:
which allows to compare to any object, without having to test for the class first.
id obj = [dict objectForKey:@"key"];
if ( [obj isEqual:@"text"] ) {
//...
}
Upvotes: 1
Reputation: 677
You can use introspection to determine whether or not an object is the same data type as another, but you'll have to do it like this (note the type id
);
id *obj = [dict objectForKey:@"key"];
if ([obj isKindOfClass:[NSString class]])
{
if ([obj isEqualToString:@"text"])
{
//...
}
}
Upvotes: 1