I have an app that lets the user input a file, process it, then lets the user save the file. I ran into a small problem with the save dialog. The file type that my app allows the user to save should only be txt files. But I do allows the user to use other types as well so I put true
in allowsOtherFileTypes
. Here is my code:
let savePanel = NSSavePanel()
savePanel.allowedFileTypes = ["txt"]
savePanel.allowsOtherFileTypes = true
savePanel.beginSheetModal(for: self.window!, completionHandler: { response in
// Save handlers here.
})
The problem is, if the user put another extension other than txt, my app suppose to pop up an alert asking for sure if the user wants to use that extension for the file, but the alert pop up as it's own window instead of a sheet:
What should I add to make this alert appear as a sheet over the save window instead of on a new window?
System: macOS Sierra, Xcode 8.2, Swift 3