You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
599 B

import AppKit
enum FolderPicker {
/// Ordnerauswahl, startet bei `current`. nil = abgebrochen.
@MainActor
static func choose(startingAt current: URL?, prompt: String = String(localized: "Wählen")) -> URL? {
let panel = NSOpenPanel()
panel.canChooseDirectories = true
panel.canChooseFiles = false
panel.canCreateDirectories = true
panel.allowsMultipleSelection = false
panel.prompt = prompt
if let current { panel.directoryURL = current }
guard panel.runModal() == .OK else { return nil }
return panel.url
}
}

Powered by TurnKey Linux.