I create/push my ViewController, display some informations and navigate back to my RootViewController. While I navigate back the app crashes (EXC_BAD_ACCESS).
With Instruments I found out that the dealloc of my ViewController is called, which releases my wrapper class. In my wrapper class also the dealloc method is called. This dealloc releases parsedJson
(retained property) and right then the app crashes. It is strange that the retain count drops from 1 to -1 despite only a malloc and a release has been made.
If I retain the returned result parsedJson
, the app doesn't crash and I don't find a leak.
SBJsonParser *JSONParser = [SBJsonParser new];
id parsedJson = [[JSONParser objectWithString:jsonString error:NULL] retain];
I can't make a release/autorelease because then the app would crash again.
With NSZombieEnabled I get
* -[CFDictionary release]: message sent to deallocated instance 0x6d51aa0
I get this Zombie after I made a change. Before I used a property and Interface Builder for my view controller and I didn't got a crash, because the view controller wasn't released immediately. Now I'm doing this:
MyViewController *myViewController = [[MyViewController alloc] init];
[[self navigationController] pushViewController:myViewController animated:YES];
[myViewController release];
myViewController = nil;
Where is the error? I cannot retain parsedJSON
without a release. I'm never releasing parsedJson
except of the dealloc. Has the used library an error in it?