Questions tagged [nsworkspace]

An NSWorkspace object responds to application requests to perform a variety of services: Opening, manipulating, and obtaining information about files and devices, Tracking changes to the file system, devices, and the user database, Getting and setting Finder information for files, Launching applications

154 questions
28
votes
3 answers

Show folder's contents in finder using Swift

I want to be able to select a folder and show its contents in the Finder. I have managed to select the folder itself and select a file within the folder. But I don't know how to show the contents of an empty folder. e.g. Folder A/Folder B I want to…
iphaaw
  • 6,764
  • 11
  • 58
  • 83
14
votes
4 answers

XCode Unit Tests - Cannot find viewcontroller in scope

At some point in my app's development, my Unit Tests and UI Tests lost access to my app's main module: Cannot find type 'FileVacuumViewController' in scope They worked with the xctestplan before. I don't know at what point it happened. I tried…
Mikeumus
  • 3,570
  • 9
  • 40
  • 65
14
votes
2 answers

How to launch system preferences to a specific preference pane using bundle identifier?

I'm trying to open the system date & time preferences directly from my app. I can seem to open System Preferences with no issue using: let settingsBundleIdentifier =…
santi_
  • 191
  • 1
  • 8
13
votes
1 answer

Cocoa: Sandbox entitlement to launch another application

I'm calling [[NSWorkspace sharedWorkspace] launchApplication:path]; From my sandboxed app, and I'm getting this error in the console: 9/5/11 12:23:12.462 PM lsboxd: refusing to spawn < PATH REDACTED > for 21383 - reason -10826 9/5/11 12:23:12.463…
SG1
  • 2,871
  • 1
  • 29
  • 41
12
votes
4 answers

Open URL with Safari no matter what system browser is set to

In my objective-c program, I need to open a URL in Safari no matter what the system's default browser is. That means that this won't work, because it could launch Firefox or whatever other browser: NSWorkspace * ws = [NSWorkspace…
Mark
  • 343
  • 1
  • 4
  • 13
11
votes
1 answer

how to get windows of NSRunningApplication

I want to get the window list for a running application. I can get the running application list from [[NSWorkspace sharedWorkspace] runningApplications], but the window list is only available on NSApplication. Is there some way to convert from…
pvinis
  • 4,059
  • 5
  • 39
  • 59
9
votes
2 answers

OSX/Swift: Call function when screen becomes available

I want my OSX app to call a function when the user's screen becomes available, ex: their computer wakes from sleep or the user turns on their screen. Basically any time the user goes from having no screen active to having one active, I would like my…
yesthisisjoe
  • 1,987
  • 2
  • 16
  • 32
6
votes
1 answer

Open user's browser, or switch to the appropriate tab if the website is already opened

In my Objective-C app, I use this code to open a website in the user's browser: [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://blah.com/"]]; This works fine. However, there is one small problem; if the user already…
houbysoft
  • 32,532
  • 24
  • 103
  • 156
6
votes
2 answers

Show in Finder not working in 10.8

This works in 10.7 but not in 10.8. How do I get this to work in Mountain Lion? -(IBAction)showTargetInFinder:(id)sender { NSString *linkPath = [targetField stringValue]; NSWorkspace *ws = [NSWorkspace sharedWorkspace]; [ws…
Paul
  • 189
  • 10
5
votes
1 answer

Any way to make file resource forks uncopyable by Finder?

Is there any way to make resource forks uncopyable? In particular I'm setting a custom badge icon to the files contained in a specific directory through NSWorkspace via – setIcon:forFile:options: and I'd like those badges to be lost as soon as the…
alediaferia
  • 2,537
  • 19
  • 22
5
votes
2 answers

Get UTI of NSPasteboardTypeFileURL

NSFilenamesPboardType got deprecated on 10.14 and the suggestion is to use NSPasteboardTypeFileURL. This gives me filename as file:///.file/id=6571367.12885025918 and NSWorkspace is unable to get UTI out of it. How to get UTI from…
Marek H
  • 5,173
  • 3
  • 31
  • 42
5
votes
3 answers

Objective C code for background processes

I have used NSApplication and NSWorkspace to get a list of running applications. But it is only giving me the applications that are active from the administrator and not the root processes that run in the background. I want to get a list of all…
Bharath Suresh
  • 483
  • 2
  • 18
5
votes
0 answers

Launching other apps in fullscreen

As I mentioned in the topic I am wondering if there is any way to run an app in fullscreen right from my app. I tried to use Accessibility, but I haven't found anything that could help. I also tried to use NSWorkspace, but the result is the same.…
5
votes
0 answers

Launch application with arguments with NSWorkspace not working

I would like to open FileZilla (ftp application) with an argument. It is working with NSTask (aka. Process): let process:Process = Process() process.launchPath = appURL.path process.arguments = ["ftp://1.2.3.4"] process.launch() It is not working…
Daniel
  • 1,473
  • 3
  • 33
  • 63
5
votes
2 answers

Cannot receive NSWorkspaceDidWakeNotification in Swift OS X

I'm making a macOS application where it's necessary to do something when the computer wakes falls asleep and wakes up, but I can't get the listener to work. I feel like I've tried everything. In AppDelegate.swift, inside of the function…
Sam Bobel
  • 1,784
  • 1
  • 15
  • 26
1
2 3
10 11