A workspace that can launch other apps and perform a variety of file-handling services.
SDK
- macOS 10.0+
Framework
- App
Kit
Declaration
@interface NSWorkspace : NSObject
Overview
There is one shared NSWorkspace
object per app. You use the class method shared
to access it. For example, the following statement uses an NSWorkspace
object to request that a file be opened in the TextEdit app:
[[NSWorkspace sharedWorkspace] openFile:@"/Myfiles/README" withApplication:@"TextEdit"];
You can use the workspace object to:
Open, manipulate, and get information about files and devices
Track changes to the file system, devices, and the user database
Get and set Finder information for files
Launch apps
Legacy Constants
Table 1 describes keys for an NSDictionary
object containing information about an app. This dictionary is returned by active
and launched
, and is also provided in the user
of NSWorkspace
notifications for app launch and termination.
Note that these constants are considered legacy.
Note
It is strongly suggested that you use the NSWorkspace
class’s running
method and the NSRunning
class to retrieve this information in apps target macOS 10.6 and later, rather than the active
and launched
methods.
userInfo dictionary keys for activeApplication and launchedApplications and notifications for app launch and termination
Key |
Value |
---|---|
|
The full path to the app, as a |
|
The app's name, as an |
|
The app’s bundle identifier, as an |
|
The app's process id, as an |
|
The high long of the process serial number (PSN), as an |
|
The low long of the process serial number (PSN), as an |