开发者

Data from TouchJSON getting deallocated

开发者 https://www.devze.com 2023-01-22 17:59 出处:网络
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

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 instan开发者_StackOverflowce 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"];
0

精彩评论

暂无评论...
验证码 换一张
取 消