0

I can't get it to show any alert if I try to use a not allowed extension. When I say "not allowed" I mean I wrote

setAllowsOtherFileTypes:FALSE

but it doesn't work. If I set the allowed file types to an array of @"jpg" and @"png" (for example), and then I try to save "file.tif", I get no alert and the resulting filename is "file.tif.jpg" What's happening? I'm on MacOS 10.6.8, Xcode 3.2.6

Thank you very much

sujal
  • 1,058
  • 3
  • 18
  • 29
user732274
  • 1,069
  • 1
  • 12
  • 28

1 Answers1

0
NSSavePanel* savepanel = [NSSavePanel savePanel];
 // set the save panel to only do jpg and png file
    [savepanel setAllowedFileTypes:[NSArray initWithObjects:@"jpg", @"png",nil]];
    [savepanel setAllowsOtherFileTypes:YES];
 // run the panel
if ([savepanel runModal] != NSFileHandlingPanelOKButton)
  return NO;
Parag Bafna
  • 22,812
  • 8
  • 71
  • 144
  • 1
    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). – Parag Bafna May 08 '12 at 19:25
  • take a look at this http://www.cocoabuilder.com/archive/cocoa/185690-nssavepanel-and-allowing-unknown-extensions.html – Parag Bafna May 08 '12 at 19:26