Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mortenjust/a5a4775fc365840b3e3c to your computer and use it in GitHub Desktop.
Save mortenjust/a5a4775fc365840b3e3c to your computer and use it in GitHub Desktop.
func selectFolder(){
let openPanel = NSOpenPanel();
openPanel.title = "Select a folder to watch for videos"
openPanel.message = "Videos you drop in the folder you select will be converted to animated gifs"
openPanel.showsResizeIndicator=true;
openPanel.canChooseDirectories = true;
openPanel.canChooseFiles = false;
openPanel.allowsMultipleSelection = false;
openPanel.canCreateDirectories = true;
openPanel.delegate = self;
openPanel.beginWithCompletionHandler { (result) -> Void in
if(result == NSFileHandlingPanelOKButton){
let path = openPanel.URL!.path!
print("selected folder is \(path)");
// self.watchFolderLabel.stringValue = path; // no need when binding
self.savePref("watchFolder", value: path);
}
}
}
@howiemnet
Copy link

Thanks - handy :)

@teusbenschop
Copy link

Thanks, useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment