0
votes

I have an app where I use NSOpenPanel:

openDlg = [NSOpenPanel openPanel];
[openDlg setCanChooseDirectories:YES];
[openDlg beginSheetModalForWindow:MainWindow completionHandler:nil];

if ([openDlg runModal] == NSOKButton){
     NSLog(@"accept");
} else {
     NSLog(@"cancel");
}

The thing is that after canceling, if I show the popup again it appears as a window, instead of sheet (which does on the first call). I think this is due to some release thing, but my project uses ARC, so I don't know. What I'm doing wrong? Thanks!

1
Can you post the code where you show the panel again, and it doesn't work? It is doubtful that the problem has anything to do with ARC or memory management. - Andrew Madsen

1 Answers

0
votes

Looks like you're accepting the value provided from the NSOpenPanel but you are then not removing the panel itself, this can be done by adding the following to the end of your code

[openDlg close];
[NSApp endSheet:openDlg];