So you want a dialog box where the user can choose a directory? If so, then you actually want an NSOpenDialog. Set canChooseDirectories to true, and canChooseFiles and allowsMultipleSelection to false.
i use it like this
NSOpenPanel* openPanel = [NSOpenPanel openPanel];
[openPanel setAllowsMultipleSelection:NO];
[openPanel setCanChooseDirectories:YES];
[openPanel setCanChooseFiles:NO];
[openPanel setCanCreateDirectories:YES];
[openPanel setTreatsFilePackagesAsDirectories:NO];
[openPanel setResolvesAliases:YES];
[openPanel beginSheetModalForWindow:controlPanel completionHandler:^(NSInteger result)
{
if (result == NSOKButton)
{
[_path setStringValue:[openPanel filename]];
}
}];
NSOpenDialog means NSOpenPanel
here the problem is,if i create a folder on desktop and select that folder
than again open the NSOpenPanel after MoveToTrash the created folder,
now create the folder with same name on desktop,now Program received signal: “EXC_BAD_ACCESS”.
and point out here
#0 0x940ee6a2 in TFSInfo::AddPtrReference
#1 0x940ef7f2 in TNode::IsContainer
#2 0x94135bbb in TNode::SetForceSync
my Mac OS X 10.6.7,
steps wise procedure:
1- click browse button to open panel
2- create a new folder on desktop an open(select) using panel
3- move to trash newly created folder but don't empty the trash.
4- click again browse button to open panel
5- select desktop and create new folder with same name
here i receive the error.
is there any mistake in my method to open panel?
[_path setStringValue:[openPanel filename]];
NSLog(@"Selected URL: %@", [openPanel URL]);