views:

17

answers:

0

I have an NSArray stored as a property of my class with a retain attribute. I use a NSURLConnection to return me data as JSON. I use TouchJSON to convert it into a NSDictionary object which I store into the array. I'm using this array as the datasource for a UITableView, but after scrolling through the table a few times I get a message sent to deallocated object error.

I get the error even if I retain receivedData and searchResults.

What am I doing wrong? Thanks!

@property(retain) NSArray *myArray;

(void)connectionDidFinishLoading:(NSURLConnection *)connection {

// Once we get response, parse it
NSError *error;
NSData *receivedData = [connectionInfo objectForKey:@"receivedData"];
NSDictionary *searchResults = [[CJSONDeserializer deserializer] deserializeAsDictionary:receivedData error:&error];

self.myArray = [searchResults objectForKey:@"myData"];

}

-[CFDictionary objectForKey:]: message sent to deallocated instance 0x14a0b70

More details: myArray is an array of dictionaries and the error occurs when I call

NSDictionary *myDict = [self.myArray objectAtIndex:indexPath.row];
[myDict objectForKey:@"id"];