I have a document-based application with 3 document types (Type A, Type B, Type C) configured as editor in the info.plist. How can I make it so that Type A will allow the user to set whatever file name they want when saving, without forcing any particular extension, while still being able to choose from the 3 different formats?
What I've tried:
allowsOtherFileTypes
to true
in my NSDocument's prepareSavePanel()
function. This isn't sufficient because it only works if the user enters an extension that isn't currently known by the system (eg “My document.foo” will still save as “My Document.foo.typea”).You have used the extension “.txt” at the end of the name. The standard extension is “.”.
So, without completely overriding the entire save process, I'm now out of ideas.
I had another idea which seems to be working on both macOS 12 and 13:
Set the type identifier of the document type to public.data
in the info.plist.
On macOS 12 this logs a warning about not having a valid extension, but it doesn't show any confusing prompts to the user. I'm still open to other solutions though, if anyone has any.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.