Note that there are some explanatory texts on larger screens.

plurals
  1. POWeird crash while accessing array objects at a given index in IOS
    primarykey
    data
    text
    <p>We have the following method where we are trying to access an array object at a given index. The array is <code>resultArr</code>. When we do a <code>resultArr</code> count it gives us a result of 13. So we know that the array is not null but when we try to do <code>objectAtIndex</code> it crashes with the error. </p> <p>Function:</p> <pre><code>- (void)fetchedData:(NSData *)responseData { //parse out the json data NSError* error; NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData //1 options:kNilOptions error:&amp;error]; NSArray *keys = [json allKeys]; NSLog(@"keys: %@",keys); NSArray* htmlAttributions = [json objectForKey:@"html_attributions"]; //2 NSArray* resultArr = (NSArray *)[json objectForKey:@"result"]; //2 NSArray* statusArr = [json objectForKey:@"status"]; //2 NSLog(@"htmlAttributions: %@",htmlAttributions); NSLog(@"result: %@", resultArr); //3 NSLog(@"status: %@", statusArr); //3 NSLog(@"resultCount: %d",[resultArr count]); [resultArr objectAtIndex:0]; } </code></pre> <p>Error:</p> <pre><code>2012-04-01 22:31:52.757 jsonParsing[5020:f803] resultCount: 13 2012-04-01 22:31:52.759 jsonParsing[5020:f803] -[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x6d2f900 2012-04-01 22:31:52.760 jsonParsing[5020:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x6d2f900' *** First throw call stack: </code></pre> <p>Thank you. </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