On 20/04/2009, at 5:51 PM, Quincey Morris wrote:

But one annoying problem remains. When exporting files (at least in my case) it's highly desirable for some formats to get a suffix on the default filename (specifically, because some of the formats require creating a folder of stuff instead of a file, and an extension on the folder isn't desirable at all), but there appears to be no way to change the filename while the dialog is displayed. There's no setFilename method, and no delegate method that appears to allow the filename to be changed.


Have I followed correctly? You want to name a folder, say <Foo>, but then place files inside called e.g. Foo_001, Foo_002 etc?

This is perfectly possible - NSFileWrapper is a convenient way to encapsulate a whole bunch of files inside a folder, and you can return a file wrapper from NSDocument's -fileWrapperOfType:error: method. It would entirely be up to your document to construct the folder the way you want it - this wouldn't be the job of NSSavePanel. The only purpose of the save panel is to return the full path where the user wants the file object(s) saved, not to perform the save, so in general it's up to the user to enter a filename as they wish. I guess the fact that there's no -setFilename: method reflects that. You can set whether the extension part is hidden of not of course.

In this case, the user enters <Foo> and you append the suffixes when you actually save the data to that Folder. Delegate methods do allow you to validate the entered filename.

It's not unreasonable to provide your own UI for handling this sort of thing if you really need something different. In one app I wrote I did something similar, where my save panel's accessory view had extra stuff for specifying how a series of automated file suffixes were built, but the main save panel simply supplied the root name and target directory.



--Graham


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to