NSSavePanel: Saving with file extension

  • I have an accessory view associated with a custom save panel. The accessory
    view lists various image formats [jpeg, gif, etc]. Currently after saving,
    the files show up as unsupported due the lack of an appended file
    extension. Manually inserting the file extension in the save panel prior to
    saving ...  or editing the saved file by adding the extension after the fact
    fixes the problem.
    How can I set things up in the savePanel so that it saves out files with the
    proper file extension based on the selection in the accessory view/

    thanks.
  • Hi Vince,

    Take a look at the 'setRequiredFileType:' instance method in the
    NSSavePanel Class Reference.
    http://tinyurl.com/467rzq

    The string you supply as an argument is the extension the file will
    get (without the period).

    To hook this up you can create an instance method 'setFileType:' in
    your controller class and set that as the target/action for the
    NSPopupButton you use in the accessoryView, in your 'setFileType:'
    implementation you can get the 'titleOfSelectedItem' or
    'indexOfSelectedItem' from the NSPopupButton (the sender of te action)
    to determine what the argument of the 'setRequiredFileType:' call to
    your export panel should be.

    Hope this answers your question,

    Dirk

    On May 26, 2008, at 3:42 PM, vince wrote:

    > I have an accessory view associated with a custom save panel. The
    > accessory
    > view lists various image formats [jpeg, gif, etc]. Currently after
    > saving,
    > the files show up as unsupported due the lack of an appended file
    > extension. Manually inserting the file extension in the save panel
    > prior to
    > saving ...  or editing the saved file by adding the extension after
    > the fact
    > fixes the problem.
    > How can I set things up in the savePanel so that it saves out files
    > with the
    > proper file extension based on the selection in the accessory view/
    >
    > thanks.
previous month may 2008 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
Go to today