I am trying to parse some JSON that I get via a web service. The logic is :
id jsonObject = ....; //This can be string or array
if([jsonObject class] == [NSString class] || [jsonObject class] == [NSMutableString class]{
// DO some thing
}
else if([jsonObject class] = [NSArray class] || [jsonObject class] == [NSMutableArray class]{
// Do some thing else
}
However for one of the elements I ran into a weird problem. The class of this element should be NSArray but when I run the code I see the class as __NSArrayM. This does not match the second if block.
Can some one tell me what I am doing wrong
use instead:
For class clusters, this is the only proper way to do it — isKindOfClass checks whether an object is an instance of a class or one of its subclasses. There’s a similar method, isMemberOfClass:, which tests for strict class equality/membership (i. e. no subclass instances are considered equal).