Good day folks. Being a .net guy I;m really strugling with this leaking memory issue, please help!
On navigation controller I'm parsing some JSON with touch-Json (tried SBJSON to same result) data from Json is displayed to a tableview. So far it's all fine and dandy. On table row click I'm pushing other xib on navigation controllers stack. New Xib gets loaded, but I'm left with all bunch of Json lib related memory leaks.
- (void)viewWillAppear:(BOOL)animated {
NSData *jsonData = [fileReadStr dataUsingEncoding:NSUTF32BigEndianStringEncoding];
NSDictionary *results = [[CJSONDeserializer deserializer]
deserializeAsDictionary:jsonData error:&theError];
//IniativesArray is used to poulated tableview on rootcontroler (first navigation xib)
//I've allso tried [[NSArray alloc] initWithArray:[results objectForKey:@"Initiative"] copyItems:YES];
IniativesArray = [[NSArray alloc] initWithArray:[results objectForKey:@"Initiative"]];
NSLog(@"Error: %@", theError);
//[results release]; <-- will crash application if uncomented
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[IniativesArray release];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
StreamsContainerViewController *StreamsContainerView = [[StreamsContainerViewController alloc] initWithNibName:@"StreamsContainerViewController" bundle:nil];
StreamsContainerView.IniativeNumber = (NSInteger)[indexPath row]; //not an actual iniative ID, just a number in array.
[self.navigationController pushViewController:StreamsContainerView animated:YES];
[StreamsContainerView release];
}
I had Json parsing code in - (void)viewDidLoad and - (void)dealloc methods accordingly, but that didn't helped. I've tried to make a deep copy of array that I need to populate tableview, and release an old array, so I'll have no pointers in any Json library objects. But that didn't helped. I'm still getting bunch of leaking JSON lib objects, that where allocated on first navigation controller xib load.