objective-cmacosnssavepanel

NSSavePanel can't change file name


In my mac app I'm using NSSavePanel - but it's behaving very strange. Sometimes I can't change the default name of the file.

I'm using it like this:

NSSavePanel *savePanel = [NSSavePanel savePanel];
[savePanel setAllowedFileTypes:@[@"jpg"]];
[savePanel setLevel:CGShieldingWindowLevel()];

if([savePanel runModal] == NSFileHandlingPanelOKButton)
{
    //saving file
}

I can't find why sometimes it lets me change the file name and other times no, I can save a file but a changing name in save panel is blocked


Solution

  • Have you tried providing a default name?

    [savePanel setNameFieldStringValue:@"New File.txt"];