Issue #405

Enable Read/Write for User Selected File under Sandbox to avoid bridge absent error

func save() {
    let panel = NSSavePanel()
    // 3
    panel.directoryURL = FileManager.default.homeDirectoryForCurrentUser
    // 4
    panel.nameFieldStringValue = "abc.gif"

    // 5
    guard let window = view.window else {
        return
    }

    panel.beginSheetModal(for: window) { (result) in
        guard result == .OK, let url = panel.url else {
            self.showAlert()
            return
        }
    }
}

func showAlert() {
    let alert = NSAlert()
    alert.messageText = "Hello world"
    alert.informativeText = "Information text"
    alert.addButton(withTitle: "OK")
    alert.addButton(withTitle: "Cancel")
    alert.runModal()
}

To save multiple files, use NSOpenPanel

let panel = NSOpenPanel()
panel.canChooseFiles = false
panel.allowsMultipleSelection = false
panel.canChooseDirectories = true
panel.directoryURL = FileManager.default.homeDirectoryForCurrentUser

Read more