• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSSavePanel and allowing unknown extensions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSSavePanel and allowing unknown extensions
      • From: Ken Baer <email@hidden>
  • Prev by Date: C++ Mac UI Developer - Cocoa & PowerPlant, Contract Job
  • Next by Date: Re: Accesing a file from a remote machine
  • Previous by thread: NSSavePanel and allowing unknown extensions
  • Next by thread: Re: NSSavePanel and allowing unknown extensions
  • Index(es):
    • Date
    • Thread