Note that there are some explanatory texts on larger screens.

plurals
  1. PONSdictionary returns error when 1 returns
    primarykey
    data
    text
    <p>Everything works when i get more then 1 objects back but when its only 1 it reacts weird, i can't find the solution for it.</p> <p>First i set everything in an array:</p> <pre><code>NSArray *array = [[[dictionary objectForKey:@"Response"] objectForKey:@"objecten"] objectForKey:@"object"]; if (array == nil) { NSLog(@"Expected 'results' array"); return; } </code></pre> <p>then i use a for loop on a dictionary</p> <pre><code>for (NSDictionary *resultDict in array) { SearchResult *searchResult; NSString *wrapperType = [resultDict objectForKey:@"type"]; if ([wrapperType isEqualToString:@"rent"]) { searchResult = [self parseHuur:resultDict]; } if (searchResult != nil) { [searchResults addObject:searchResult]; }} </code></pre> <p>So when results get back more then 1 everything works great, but when just one gets back i get:</p> <pre><code>-[__NSCFString objectForKey:]: unrecognized selector sent to instance 0x6e52c30 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectForKey:]: unrecognized selector sent to instance 0x6e52c30' </code></pre> <p>it points to this line: </p> <pre><code>NSString *wrapperType = [resultDict objectForKey:@"type"]; </code></pre> <p>I really don't get it... i check the results of the api in the browser with the same link and it really returns 1 object, but when i log the resultDict (NSlog it) i get only one answer: id instead of the whole object with all parameters (i don't know if this is the right name for it)</p> <p>how can that be ?</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.
    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