Check whether an object is an NSArray or NSDictionary

As per subject, how can I check whether an object is an NSArray or NSDictionary?


if([obj isKindOfClass:[NSArray class]]){
    //Is array
}else if([obj isKindOfClass:[NSDictionary class]]){
    //is dictionary
}else{
    //is something else
}

Try

[myObject isKindOfClass:[NSArray class]]

and

[myObject isKindOfClass:[NSDictionary class]]

Both of these should return BOOL values. This is basic use of the NSObject method:

-(BOOL)isKindOfClass:(Class)aClass

For a bit more information, see this answer here: In Objective-C, how do I test the object type?