Re: NSSavePanel and allowing unknown extensions
Re: NSSavePanel and allowing unknown extensions
- Subject: Re: NSSavePanel and allowing unknown extensions
- From: Peter Duniho <email@hidden>
- Date: Fri, 6 Jul 2007 02:23:41 -0700
From: Ken Baer <email@hidden>
I'm having a problem with getting a save dialog to not append the
extension on the end the filename when the user types in a different
extension. [...] Here is some sample code.
NSSavePanel* saveDialog = [NSSavePanel savePanel];
[saveDialog setAllowedFileTypes:[NSArray
arrayWithObject:@"mov"]];
[saveDialog setAllowsOtherFileTypes:YES];
if ([saveDialog runModal] != NSFileHandlingPanelOKButton)
return NO;
Am I missing something?
I have code that looks pretty much just like that, and it does what
I'd expect: if the user enters a filename with an extension other
than those allowed, a dialog pops up asking if the user really wants
to use the extension they entered.
Note that the dialog only appears if the alternative extension the
user enters is one that is recognized (by the OS, I think, but I
suppose it could be something specific in Cocoa). If it's not a
recognized extension, then the filename is treated as though it has
no extension, and your provided extension is appended.
I presume that this behavior is to deal with the common case of files
that have periods in their names, but which don't really have an
extension per se. Much more common in the *nix world than for
traditional PCs (Mac and Windows).
Does that help?
Pete
_______________________________________________
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