I'm trying to present a viewcontroller modally:
- (IBAction)addReference {
ReferenceAddViewController *referenceAddViewController = [[ReferenceAddViewController alloc] initWithNibName:@"ReferenceAddViewController" bundle:nil];
[referenceAddViewController setDelegate:self];
[self presentModalViewController:referenceAddViewController animated:YES];
[referenceAddViewController release];
}
However, if I call [referenceAddViewController release], later on when the modal view is dismissed, my app crashes with "[CALayer release]: message sent to deallocated instance 0x4b90370".
Doing a stack trace and reference count history in Instruments didn't give away anything conclusive, with only two history steps.
- 0: Retain count 1 - Malloc by presentModalViewController in my code.
- 1: Retain count -1 - nothing in my code apart from main.m
It is very interesting on how the reference count skips from 1 to -1? Does Instruments record every reference count change?
How would I go about debugging this issue further?