Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mkristain

macrumors regular
Original poster
Aug 18, 2011
115
0
i want to use NSSavePanel to select the saving folder location ,so i don't want to use save as option.

i want here only folders are visible or selectable.

please guide me how can i do this.

thanks.
 
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.
 
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.

NSOpenDialog means NSOpenPanel

Code:
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]];
				 
				 
			 }
		 }];

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

so please help me for this.

thanks.
 
NSOpenDialog means NSOpenPanel

Please accept my sincerest apology for that mistake.


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

I cannot reproduce your problem a test project under Mac OS X 10.7.2. I opened an NSOpenPanel, created a folder on my desktop and selected that folder. I then moved the newly created folder to the trash. When I opened the NSOpenPanel again, it reverted to my Documents folder. It didn't get an EXC_BAD_ACCESS signal.


BTW The NSOpenPanel's filename is deprecated. You should be using URLs instead of string paths.
 
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.
 
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.

Sorry again. I didn't pick up on that you were selecting a second newly created folder that happened to have the same path as the now trashed, previously selected folder. I tried that but again I didn't get an EXC_BAD_ACCESS signal.

Does the EXC_BAD_ACCESS occur as soon as as you click Create, or is it after you click Open?
 
some time on click Create, or sometimes on click Open

why i receiving this every time,

is there any mistake in my method to open panel?
 
is there any mistake in my method to open panel?

I've been using your code, with one difference.

Instead of your line:
Code:
[_path setStringValue:[openPanel filename]];

I have:
Code:
NSLog(@"Selected URL: %@", [openPanel URL]);
 
i am using [_path setStringValue:[openPanel filename]]; because i display the selected path in this text field.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.