Search code examples
objective-creflectionjsonkit

Test if object is JKArray


I want to see if the results of this call:

NSDictionary *results = [jsonString objectFromJSONString];
id contacts=[[results objectForKey:@"list"] objectForKey:@"Contact"];

Return an array or a dictionary.

I tried this:

    [contactdict isKindOfClass:[JKArray class]];

but JKArray is statically declared in the JSONKit.m file, so the xcode can't see it.


Solution

  • This is what NSClassFromString is for:

    if ([contactDict isKindOfClass:NSClassFromString(@"JKArray")])
    {
        // do stuff here
    }