Created
January 22, 2020 03:44
-
-
Save justinmeiners/d19ada5bb007f26122196d33fa00ba6d to your computer and use it in GitHub Desktop.
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
NSOpenPanel *panel; | |
NSArray* fileTypes = [NSArray arrayWithObjects:@"pdf", @"PDF", nil]; | |
panel = [NSOpenPanel openPanel]; | |
[panel setFloatingPanel:YES]; | |
[panel setCanChooseDirectories:NO]; | |
[panel setCanChooseFiles:YES]; | |
[panel setAllowsMultipleSelection:YES]; | |
[panel setAllowedFileTypes:fileTypes]; | |
int i = [panel runModal]; | |
if (i == NSOKButton){ | |
return [panel URLs]; | |
} |
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
let fileTypes = ["jpg", "png", "jpeg"] | |
let panel = NSOpenPanel() | |
panel.canChooseFiles = true | |
panel.canChooseDirectories = false | |
panel.allowsMultipleSelection = false | |
panel.allowedFileTypes = fileTypes | |
panel.beginSheetModal(for: window) { (result) in | |
if result.rawValue == NSApplication.ModalResponse.OK.rawValue { | |
// Do something with the result. | |
let selectedFolder = panel.urls[0] | |
print(selectedFolder) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment