I get a EXC_BAD_ACCESS while running a NSOpenPanel to select a directory on the file system.
The app crashes only if I create a new folder (with the default “New Folder” button) and then I select it and open it (with the default “Open” button.
If I just open an existing folder everything works.
NSOpenPanel *browsePanel = [[NSOpenPanel alloc] init];
[browsePanel setCanChooseFiles:NO];
[browsePanel setCanChooseDirectories:YES];
[browsePanel setCanCreateDirectories:YES];
[browsePanel beginSheetForDirectory:nil
file:nil
types:nil
modalForWindow:self.window
modalDelegate:self
didEndSelector:@selector(browsePanelPanelDidEnd:returnCode:contextInfo:)
contextInfo:[NSNumber numberWithInteger:[sender tag]]];
The app crashes before the didEndSelector is invoked.
thanks
ps. I’ve tried to set contextInfo to nil, and it crashes anyway.
THis normally happens because you are sending a message to a deallocated object. Also known as a Zombie. There are two things you can do, first run the app with NSZombieEnabled=YES, or secondly run instruments and hunt for zombies. I would recommend using instruments as it gives the best feedback and allows you to explore the data.
Enabling Zombie detection will show you which object is being sent the message and allow you to hunt down either why you are sending the message or why you are deallocating something you want.
You code above is not enough detail to figure this out. It’s not unusual for the Zombie to be in a completely different section of code because it’s all about deallocated instances. Something you may have done elsewhere.