質問

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.

役に立ちましたか?

解決

This is what NSClassFromString is for:

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

他のヒント

You may be able to simply add @class JKArray; to the top of the file where you're making this call. That just tells the compiler that there is a class named JKArray. The actual test happens at runtime of course.

Alternatively, you should be able do this:

[[contactDict className] isEqualToString:@"JKArray"];

or this:

[contactDict isKindOfClass:NSClassFromString(@"JKArray")];
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top