Created
October 25, 2024 17:49
-
-
Save delasign/5d88ca97de29ed04140e9c6719f24279 to your computer and use it in GitHub Desktop.
Sample get file or folder url Swift function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| @MainActor | |
| private func getFolderURL(title: String, message: String, canChooseFiles: Bool, canChooseDirectories: Bool, allowsMultipleSelection: Bool) async -> URL? { | |
| let panel = NSOpenPanel() | |
| panel.title = title | |
| panel.message = message | |
| panel.canChooseFiles = canChooseFiles | |
| panel.canChooseDirectories = canChooseDirectories | |
| panel.allowsMultipleSelection = allowsMultipleSelection | |
| switch panel.runModal() { | |
| case .OK: | |
| return panel.url | |
| default: | |
| return nil | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment