Using NSSavePanel to export to UTTypeFolder without a file extension.
Using NSSavePanel to export to UTTypeFolder without a file extension.
- Subject: Using NSSavePanel to export to UTTypeFolder without a file extension.
- From: Thomas Bunch <email@hidden>
- Date: Thu, 17 Jan 2013 14:12:25 -0800
Hi folks,
NSSavePanel does not like UTTypes with no file extension. Under PowerBox, I can't find a good workaround.
One of OmniPlan's export types is a directory full of HTML and associated resources. Being an old NeXT guy, I immediately called this a .htmld file, but when the feature was debuted, the file extension was universally reviled. The most salient feedback was that real users tend to have file extensions hidden, and when they deploy this export to a web server they don't tend to realize that the file extension is part of the URL and compose their hyperlinks accordingly. People just want a directory with no file extension.
I'm certain I'm not the only one who has encountered this issue, but Google is not providing anything useful.
If you set things up in a way that ought to work (says I) you set yourself up for potential data-loss. When you switch file types on the NSSavePanel, the file extension is managed for you. If one of your exportable types has no file extension, it just leaves the extension from the prior selected file type. When people are exporting reports and so forth, they are quite accustomed to blowing away the previous revision of the report. In this case, the inevitable result is that they will replace their document, foo.oplx, with a directory called foo.oplx that in fact contains HTML and friends.
To see this in action, download and build the following sample project:
https://www.dropbox.com/s/vqun19at5efzjrc/NSSavePanel-kUTTypeFolder.zip
Launch, take your "document" (very much a stub), File -> Export…, "My Flat Format". Now File -> Export… again but this time pick "My HTML Folder Export". If you have your file extensions visible you'll see at this point that the extension is ".mff". Even so, the typical user will blow away their document at this point without a second thought.
Remember that we're under PowerBox here, so the URL returned by the save panel is the one we must use. There is no sanitizing it later.
This might be a good time to agitate for -[NSDocument changeSaveType:] to be made public. With recent changes to NSSavePanel (especially observing its accessoryPanel's frame) this is less critical now, and in fact there is nothing you can do here to rectify the issue at hand.
Did I remember to ask a question? Right… has anyone managed to get NSSavePanel to work properly with exportable types that have no extension. And if not, has a successor to the .htmld extension emerged that has traction?
Thanks.
-Tom
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden