Skip to content

Instantly share code, notes, and snippets.

@mortenjust
Created October 7, 2015 22:39
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mortenjust/fedf0a297d8b7e904826 to your computer and use it in GitHub Desktop.
Save mortenjust/fedf0a297d8b7e904826 to your computer and use it in GitHub Desktop.
func openAndSelectFile(filename:String){
let files = [NSURL(fileURLWithPath: filename)];
NSWorkspace.sharedWorkspace().activateFileViewerSelectingURLs(files);
}
@ingconti
Copy link

swift 5.x:

func openAndSelectFile(filename:String){
let files = [URL(fileURLWithPath: filename)];
NSWorkspace.shared.activateFileViewerSelecting(files);
}

@teusbenschop
Copy link

Thank you, that helps!

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