I'm trying to show NSSavePanel (or any "Save File Dialog") on Mac OSX. I'm building COCOA application in XCode Version 9.3 (9E145) in Swift 4 (or 4.2? I'm not sure exactly).
I've tried everything...
Like this?
let savePanel = NSSavePanel()
savePanel.begin { (result) in
if result.rawValue == NSApplication.ModalResponse.OK.rawValue {
}
}
this?
let savePanel = NSSavePanel()
savePanel.canCreateDirectories = true
savePanel.showsTagField = false
savePanel.nameFieldStringValue = "result.csv"
savePanel.level = NSWindow.Level(rawValue: Int(CGWindowLevelForKey(.modalPanelWindow)))
savePanel.begin { (result) in
if result.rawValue == NSApplication.ModalResponse.OK.rawValue {
}
}
many many other ways...
What am I missing? Thanks!
Is your application sandboxed? (Project > Capabilities > App Sandbox)
If so, ensure that you change "File Access" for "User Selected File" to Read/Write.
When I do that, your first snippet works fine for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With