Mark
Mark

Reputation: 6977

NSWorkspace selectFile:inFileViewerRootedAtPath: does not work the first time it is called

I have a sandboxed Cocoa app. I noticed that when I call [[NSWorkspace sharedWorkspace] selectFile:path inFileViewerRootedAtPath:path] no Finder window opens the first time is called. Finder.app is brought to the foreground (menu bar changes to Finder), but otherwise nothing happens.

When I bring my app back to the front and again have it select a file in Finder, the Finder window opens with the file selected as expected. I tried this with @"" as second argument, same thing.

When a Finder window is open already, everything works as expected.

Has anybody else seen this problem? Workaround is to immediately call selectFile:... twice, but that doesn't seem right.

Edit: not related to sandboxing. Same issue without sandbox.

Upvotes: 1

Views: 1065

Answers (1)

Moose
Moose

Reputation: 2737

I think activateFileViewerSelectingURLs is better. It correctly selects multiple files in the finder.

Upvotes: 2

Related Questions