Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You're not getting back a multi-dimensional array. You're getting back an array of NSDictionary objects. The error you got indicates that you're trying to send the message <code>objectAtIndex:</code> to an NSDictionary object, which fails since it has no such selector.</p> <hr> <p><strong>Update:</strong></p> <p>After chatting on the side, it became apparent that the following was true:</p> <ol> <li>The user was using the SBJson library to parse the return value from his php web service.</li> <li>The return value was <strong><em>either</em></strong>: <ul> <li>An NSDictionary with each key being the text representation of its (non-index-based) location in the list (@"1", @"2", etc...) and each value being an NSArray of NSString objects, <strong><em>or</em></strong></li> <li>An NSArray of NSString objects (seems to be the way a single "answer" returns)</li> </ul></li> </ol> <p>Here's the code I supplied to let him iterate through his return value:</p> <pre><code>NSURL *url = [NSURL URLWithString:@"{his url}"]; NSError *error; NSStringEncoding encoding; NSString *response = [[NSString alloc] initWithContentsOfURL:url usedEncoding:&amp;encoding error:&amp;error]; const char *convert = [response UTF8String]; NSString *responseString = [NSString stringWithUTF8String:convert]; NSLog(@"%@", responseString); SBJsonParser *parser = [[SBJsonParser alloc] init]; id sample = [parser objectWithString:responseString]; if ([sample isKindOfClass:[NSDictionary class]]) { for (id item in sample) { NSLog(@"%@", [item description]); NSArray *subArray = [sample objectForKey:item]; // b/c I know it's an array for (NSString *str in subArray) { NSLog(@"item: %@", str); } } } else if ([sample isKindOfClass:[NSArray class]]) { for (NSString *str in sample) { NSLog(@"item: %@", str); } } </code></pre> <p>Hope it helps, J!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload