Hi,

I show an NSSavePanel that offers the option to hide the file extension. It 
also offers the user to switch between saving .txt and .rtf formats.

When the user changes the format, the following code is run:

- (IBAction)formatForTextExportChanged:(id)sender
{    
    self.textExportFormat = [sender indexOfSelectedItem];
    
    NSString *path = 
self.currentSavePanel.nameFieldStringValue.stringByDeletingPathExtension;
    
    switch (self.textExportFormat) {
        case 0:
            path = [path stringByAppendingPathExtension:@"txt"];
            break;
        case 1:
            path = [path stringByAppendingPathExtension:@"rtf"];
            break;
    }
    
    self.currentSavePanel.nameFieldStringValue = path;

    [[NSUserDefaults standardUserDefaults] setValue:[NSNumber 
numberWithInteger:self.textExportFormat]
                                                                                
         forKey:ANTextExportFormatKey];
}

This works fine when the extension is being shown. However, when the extension 
is not shown, although the code appears to work while in the panel, when the 
panel is dismissed, the URL returned has the extension of the original format. 
How do I ensure the URL returned b the save panel ends on the user selected 
choice, even when the extension is hidden? I can't directly set the save 
panel's URL since it is read only. SInce the app is snadboxed, I need the save 
panel to return the correct URL, otherwise we later don't have permission to 
write to the URL, if I change it afterwards.

-António

----------------------------------------------------
There is a world of difference between
searching for happiness and choosing
to be happy.
----------------------------------------------------




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to