Reputation: 11450
I have the following code that creates a modal navigation controller and presents it.
DetailViewController *content = [[DetailViewController alloc]initWithNibName:@"DetailView" bundle:nil];
content.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Close"
style:UIBarButtonItemStylePlain
target:content
action:@selector(closeButtonPress:)] autorelease];
UINavigationController *modalNavController = [[UINavigationController alloc] initWithRootViewController:content];
modalNavController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:modalNavController animated:YES];
[modalNavController release];
This works fine 99% of the time but on the odd occasion I get a crash..
-[__NSCFType closeButtonPress:]: unrecognized selector sent to instance 0x5ca91d0
Upvotes: 0
Views: 250
Reputation: 90117
The code looks (almost) correct at first sight. But you should release content somewhere, but it's unlikely that the ExcBadAccess happens because of this.
So to hunt this down I would suggest to use NSZombies. NSZombies prevents that your objects get deallocated, they are just marked as deallocated (i.e. turned into zombies).
Executable
group in your xcode (3.x) sidebarGet Info
on your executableArguments
tabVariables to be set in the environment
NSZombieEnabled
and set its value to YES
. Make sure that it is activatedWhen you know where it happens you can better investigate why it happens.
Upvotes: 1