Note that there are some explanatory texts on larger screens.

plurals
  1. POJSON Parsing with NSDictionary and finding value by key
    primarykey
    data
    text
    <p>I have a simple <code>NSDictionary</code> that I am trying to populate with data from an external site via JSON that is returned. The JSON that is returned is fine but I am haveing trouble getting actual data for a specific key.</p> <p>Here is the JSON data printed to the console.</p> <p>This is my JSON data:</p> <pre><code>( { CategoryID = 12345; CategoryName = "Baked Goods"; }, { CategoryID = 12346; CategoryName = Beverages; }, { CategoryID = 12347; CategoryName = "Dried Goods"; }, { CategoryID = 12348; CategoryName = "Frozen Fruit &amp; Vegetables"; }, { CategoryID = 12349; CategoryName = Fruit; }, { CategoryID = 12340; CategoryName = "Purees &amp; Soups"; }, { CategoryID = 12341; CategoryName = Salad; }, { CategoryID = 12342; CategoryName = "Snack Items"; }, { CategoryID = 12343; CategoryName = Vegetables; } ) </code></pre> <p>The error I am getting is: </p> <blockquote> <p>Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFArray enumerateKeysAndObjectsUsingBlock:]: unrecognized selector sent to instance 0x6884000'</p> </blockquote> <pre><code>- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { NSError *error = nil; // Get the JSON data from the website NSDictionary *categories = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&amp;error]; if (categories.count &gt; 0){ NSLog(@"This is my JSON data %@", categories); [categories enumerateKeysAndObjectsUsingBlock: ^(__strong id key, __strong id obj, BOOL *stop) { NSLog(@"Key = %@, Object For Key = %@", key, obj); }]; } </code></pre> <p>I'm not sure why this is happening but I'm sure it's something simple like I am using the incorrect object or something.</p> <p>Help is appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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