Reputation: 3
I am getting NSObject * myObject
on a receiver's side. Sender can send me (NSArray *)
or (NSDictionary *)
type.
How can I check if I get (NSArray *)
?
Something like:
NSObject * myObject;
....
if (typeof(myObject) == (NSArray *))
{
} else if (typeof(myObject) == (NSDictionary *))
Any idea?
Upvotes: 0
Views: 1397
Reputation: 8202
You need to use -isKindOfClass:
if ([myObject isKindOfClass:[NSArray class]]) {
// Array
} else if ([myObject isKindOfClass:[NSDictionary class]]) {
// Dictionary
}
Upvotes: 1