<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSWorkspace",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSWorkspace"
  },
  "title" : "NSWorkspace"
}
-->

# NSWorkspace

A workspace that can launch other apps and perform a variety of file-handling services.

```
class NSWorkspace
```

## Overview

There is one shared [`NSWorkspace`](/documentation/AppKit/NSWorkspace) object per app. You use the class method [`shared`](/documentation/AppKit/NSWorkspace/shared) to access it. For example, the following statement uses an [`NSWorkspace`](/documentation/AppKit/NSWorkspace) object to request that a file be opened in the TextEdit app:

```objc
[[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.

## Topics

### Accessing the Shared Workspace

[`shared`](/documentation/AppKit/NSWorkspace/shared)

The shared workspace object.

### Accessing the Workspace Notification Center

[`notificationCenter`](/documentation/AppKit/NSWorkspace/notificationCenter)

The notification center for workspace notifications.

### Opening URLs

[`open(_:configuration:completionHandler:)`](/documentation/AppKit/NSWorkspace/open(_:configuration:completionHandler:))

Opens a URL asynchronously using the provided options.

[`open(_:withApplicationAt:configuration:completionHandler:)`](/documentation/AppKit/NSWorkspace/open(_:withApplicationAt:configuration:completionHandler:))

Opens one or more URLs asynchronously in the specified app using the provided options.

[`open(_:)`](/documentation/AppKit/NSWorkspace/open(_:))

Opens the location at the specified URL.

### Launching and Hiding Apps

[`openApplication(at:configuration:completionHandler:)`](/documentation/AppKit/NSWorkspace/openApplication(at:configuration:completionHandler:))

Launches the app at the specified URL and asynchronously reports back on the app’s status.

[`hideOtherApplications()`](/documentation/AppKit/NSWorkspace/hideOtherApplications())

Hides all applications other than the sender.

### Managing Open Configurations

[`NSWorkspace.OpenConfiguration`](/documentation/AppKit/NSWorkspace/OpenConfiguration)

The configuration options for opening URLs or launching apps.

### Manipulating Files

[`duplicate(_:completionHandler:)`](/documentation/AppKit/NSWorkspace/duplicate(_:completionHandler:))

Duplicates the specified URLS asynchronously in the same manner as the Finder.

[`recycle(_:completionHandler:)`](/documentation/AppKit/NSWorkspace/recycle(_:completionHandler:))

Moves the specified URLs to the trash in the same manner as the Finder.

[`activateFileViewerSelecting(_:)`](/documentation/AppKit/NSWorkspace/activateFileViewerSelecting(_:))

Activates the Finder, and opens one or more windows selecting the specified files.

[`selectFile(_:inFileViewerRootedAtPath:)`](/documentation/AppKit/NSWorkspace/selectFile(_:inFileViewerRootedAtPath:))

Selects the file at the specified path.

### Manipulating Uniform Type Identifier Information

[`type(ofFile:)`](/documentation/AppKit/NSWorkspace/type(ofFile:))

Returns the uniform type identifier of the specified file, if it can be determined.

[`localizedDescription(forType:)`](/documentation/AppKit/NSWorkspace/localizedDescription(forType:))

Returns the localized description for the specified Uniform Type Identifier (UTI).

[`preferredFilenameExtension(forType:)`](/documentation/AppKit/NSWorkspace/preferredFilenameExtension(forType:))

Returns the preferred filename extension for the specified Uniform Type Identifier (UTI).

[`filenameExtension(_:isValidForType:)`](/documentation/AppKit/NSWorkspace/filenameExtension(_:isValidForType:))

Returns whether the specified filename extension is appropriate for the Uniform Type Identifier (UTI).

[`type(_:conformsToType:)`](/documentation/AppKit/NSWorkspace/type(_:conformsToType:))

Returns a Boolean indicating that the first Uniform Type Identifier (UTI) conforms to the second UTI.

### Requesting Information

[`urlForApplication(toOpen:)`](/documentation/AppKit/NSWorkspace/urlForApplication(toOpen:)-7qkzf)

Returns the URL to the default app to open the specified URL.

[`urlForApplication(toOpen:)`](/documentation/AppKit/NSWorkspace/urlForApplication(toOpen:)-95cvp)

Returns the URL to the default app to open the specified content type.

[`urlForApplication(withBundleIdentifier:)`](/documentation/AppKit/NSWorkspace/urlForApplication(withBundleIdentifier:))

Returns the URL to the default app with the specified bundle identifier.

[`urlsForApplications(toOpen:)`](/documentation/AppKit/NSWorkspace/urlsForApplications(toOpen:)-ualk)

Returns an array of URLs to all available applications that can open the URL.

[`urlsForApplications(toOpen:)`](/documentation/AppKit/NSWorkspace/urlsForApplications(toOpen:)-60rkm)

Returns an array of URLs to all available applications that can open the specified content type.

[`urlsForApplications(withBundleIdentifier:)`](/documentation/AppKit/NSWorkspace/urlsForApplications(withBundleIdentifier:))

Returns an array of URLs to all available applications that can open the specified bundle identifier.

[`getFileSystemInfo(forPath:isRemovable:isWritable:isUnmountable:description:type:)`](/documentation/AppKit/NSWorkspace/getFileSystemInfo(forPath:isRemovable:isWritable:isUnmountable:description:type:))

Returns information about the file system at the specified path.

[`isFilePackage(atPath:)`](/documentation/AppKit/NSWorkspace/isFilePackage(atPath:))

Determines whether the specified path is a file package.

[`frontmostApplication`](/documentation/AppKit/NSWorkspace/frontmostApplication)

Returns the frontmost app, which is the app that receives key events.

[`runningApplications`](/documentation/AppKit/NSWorkspace/runningApplications)

Returns an array of running apps.

[`menuBarOwningApplication`](/documentation/AppKit/NSWorkspace/menuBarOwningApplication)

Returns the app that owns the currently displayed menu bar.

[`getInfoForFile(_:application:type:)`](/documentation/AppKit/NSWorkspace/getInfoForFile(_:application:type:))

Retrieves information about the specified file.

### Setting Default Application Information

[`setDefaultApplication(at:toOpenFileAt:completion:)`](/documentation/AppKit/NSWorkspace/setDefaultApplication(at:toOpenFileAt:completion:))

Sets the default app to use when opening a specific file.

[`setDefaultApplication(at:toOpen:completion:)`](/documentation/AppKit/NSWorkspace/setDefaultApplication(at:toOpen:completion:))

Sets the default app to use when opening files of a specific content type.

[`setDefaultApplication(at:toOpenContentTypeOfFileAt:completion:)`](/documentation/AppKit/NSWorkspace/setDefaultApplication(at:toOpenContentTypeOfFileAt:completion:))

Sets the default app to use when opening files of a specific content type defined by a file URL.

[`setDefaultApplication(at:toOpenURLsWithScheme:completion:)`](/documentation/AppKit/NSWorkspace/setDefaultApplication(at:toOpenURLsWithScheme:completion:))

Sets the default app to use when opening files of a specific scheme.

### Managing Icons

[`icon(forFile:)`](/documentation/AppKit/NSWorkspace/icon(forFile:))

Returns an image containing the icon for the specified file.

[`icon(forFiles:)`](/documentation/AppKit/NSWorkspace/icon(forFiles:))

Returns an image containing the icon for the specified files.

[`icon(for:)`](/documentation/AppKit/NSWorkspace/icon(for:))

Returns an image containing the icon for the specified content type.

[`setIcon(_:forFile:options:)`](/documentation/AppKit/NSWorkspace/setIcon(_:forFile:options:))

Sets the icon for the file or directory at the specified path.

[`NSWorkspace.IconCreationOptions`](/documentation/AppKit/NSWorkspace/IconCreationOptions)

Constants that describe options for creating icons.

### Unmounting a Device

[`unmountAndEjectDevice(atPath:)`](/documentation/AppKit/NSWorkspace/unmountAndEjectDevice(atPath:))

Unmounts and ejects the device at the specified path.

[`unmountAndEjectDevice(at:)`](/documentation/AppKit/NSWorkspace/unmountAndEjectDevice(at:))

Attempts to eject the volume mounted at the given path.

### Managing the Desktop Image

[`desktopImageURL(for:)`](/documentation/AppKit/NSWorkspace/desktopImageURL(for:))

Returns the URL for the desktop image for the given screen.

[`setDesktopImageURL(_:for:options:)`](/documentation/AppKit/NSWorkspace/setDesktopImageURL(_:for:options:))

Sets the desktop image for the given screen to the image at the specified URL.

[`desktopImageOptions(for:)`](/documentation/AppKit/NSWorkspace/desktopImageOptions(for:))

Returns the desktop image options for the given screen.

[`NSWorkspace.DesktopImageOptionKey`](/documentation/AppKit/NSWorkspace/DesktopImageOptionKey)

Keys that indicate how to display a new desktop image.

### Performing Finder Spotlight Searches

[`showSearchResults(forQueryString:)`](/documentation/AppKit/NSWorkspace/showSearchResults(forQueryString:))

Displays a Spotlight search results window in Finder for the specified query string.

### Finder File Labels

[`fileLabels`](/documentation/AppKit/NSWorkspace/fileLabels)

The array of file labels, returned as strings.

[`fileLabelColors`](/documentation/AppKit/NSWorkspace/fileLabelColors)

The array of colors for the file labels.

### Tracking Changes to the File System

[`noteFileSystemChanged(_:)`](/documentation/AppKit/NSWorkspace/noteFileSystemChanged(_:))

Informs the workspace object that the file system changed at the specified path.

### Requesting Additional Time Before Logout

[`extendPowerOff(by:)`](/documentation/AppKit/NSWorkspace/extendPowerOff(by:))

Requests the system wait for the specified amount of time before turning off the power or logging out the user.

### Supporting Accessibility

[`accessibilityDisplayShouldDifferentiateWithoutColor`](/documentation/AppKit/NSWorkspace/accessibilityDisplayShouldDifferentiateWithoutColor)

A Boolean value that indicates whether the app avoids conveying information through color alone.

[`accessibilityDisplayShouldIncreaseContrast`](/documentation/AppKit/NSWorkspace/accessibilityDisplayShouldIncreaseContrast)

A Boolean value that indicates whether the app presents a high-contrast user interface.

[`accessibilityDisplayShouldReduceTransparency`](/documentation/AppKit/NSWorkspace/accessibilityDisplayShouldReduceTransparency)

A Boolean value that indicates whether the app avoids using semitransparent backgrounds.

[`accessibilityDisplayShouldInvertColors`](/documentation/AppKit/NSWorkspace/accessibilityDisplayShouldInvertColors)

A Boolean value that indicates whether the accessibility option to invert colors is in an enabled state.

[`accessibilityDisplayShouldReduceMotion`](/documentation/AppKit/NSWorkspace/accessibilityDisplayShouldReduceMotion)

A Boolean value that indicates whether the accessibility option to reduce motion is in an enabled state.

[`isSwitchControlEnabled`](/documentation/AppKit/NSWorkspace/isSwitchControlEnabled)

A Boolean value that indicates whether Switch Control is currently running.

[`isVoiceOverEnabled`](/documentation/AppKit/NSWorkspace/isVoiceOverEnabled)

A Boolean value that indicates whether VoiceOver is currently running.

### Performing Privileged Operations

[`requestAuthorization(to:completionHandler:)`](/documentation/AppKit/NSWorkspace/requestAuthorization(to:completionHandler:))

Requests authorization to perform a privileged file operation.

[`NSWorkspace.Authorization`](/documentation/AppKit/NSWorkspace/Authorization)

The authorization granted to the app by the user.

[`NSWorkspace.AuthorizationType`](/documentation/AppKit/NSWorkspace/AuthorizationType)

The types of privileged file operations that can be authorized by the user.

### Responding to Environment Notifications

[`willLaunchApplicationNotification`](/documentation/AppKit/NSWorkspace/willLaunchApplicationNotification)

A notification that the workspace posts when the Finder is about to launch an app.

[`didLaunchApplicationNotification`](/documentation/AppKit/NSWorkspace/didLaunchApplicationNotification)

A notification that the workspace posts when a new app starts up.

[`didTerminateApplicationNotification`](/documentation/AppKit/NSWorkspace/didTerminateApplicationNotification)

A notification that the workspace posts when an app finishes executing.

[`sessionDidBecomeActiveNotification`](/documentation/AppKit/NSWorkspace/sessionDidBecomeActiveNotification)

A notification that the workspace posts after a user session switches in.

[`sessionDidResignActiveNotification`](/documentation/AppKit/NSWorkspace/sessionDidResignActiveNotification)

A notification that the workspace posts before a user session switches out.

[`didHideApplicationNotification`](/documentation/AppKit/NSWorkspace/didHideApplicationNotification)

A notification that the workspace posts when the Finder hides an app.

[`didUnhideApplicationNotification`](/documentation/AppKit/NSWorkspace/didUnhideApplicationNotification)

A notification that the workspace posts when the Finder unhides an app.

[`didActivateApplicationNotification`](/documentation/AppKit/NSWorkspace/didActivateApplicationNotification)

A notification that the workspace posts when the Finder is about to activate an app.

[`didDeactivateApplicationNotification`](/documentation/AppKit/NSWorkspace/didDeactivateApplicationNotification)

A notification that the workspace posts when the Finder deactivates an app.

[`didRenameVolumeNotification`](/documentation/AppKit/NSWorkspace/didRenameVolumeNotification)

A notification that the workspace posts when a volume changes its name or mount path.

[`didMountNotification`](/documentation/AppKit/NSWorkspace/didMountNotification)

A notification that the workspace posts when a new device mounts.

[`willUnmountNotification`](/documentation/AppKit/NSWorkspace/willUnmountNotification)

A notification that the workspace posts when the Finder is about to unmount a device.

[`didUnmountNotification`](/documentation/AppKit/NSWorkspace/didUnmountNotification)

A notification that the workspace posts when the Finder unmounts a device.

[`didChangeFileLabelsNotification`](/documentation/AppKit/NSWorkspace/didChangeFileLabelsNotification)

A notification that the workspace posts when the Finder file labels or colors change.

[`activeSpaceDidChangeNotification`](/documentation/AppKit/NSWorkspace/activeSpaceDidChangeNotification)

A notification that the workspace posts when a Spaces change occurs.

[`didWakeNotification`](/documentation/AppKit/NSWorkspace/didWakeNotification)

A notification that the workspace posts when the device wakes from sleep.

[`willPowerOffNotification`](/documentation/AppKit/NSWorkspace/willPowerOffNotification)

A notification that the workspace posts when the user requests a logout or powers off the device.

[`willSleepNotification`](/documentation/AppKit/NSWorkspace/willSleepNotification)

A notification that the workspace posts before the device goes to sleep.

[`screensDidSleepNotification`](/documentation/AppKit/NSWorkspace/screensDidSleepNotification)

A notification that the workspace posts when the device’s screen goes to sleep.

[`screensDidWakeNotification`](/documentation/AppKit/NSWorkspace/screensDidWakeNotification)

A notification that the workspace posts when the device’s screens wake.

[`accessibilityDisplayOptionsDidChangeNotification`](/documentation/AppKit/NSWorkspace/accessibilityDisplayOptionsDidChangeNotification)

A notification that the workspace posts when any of the accessibility display options change.

[`localizedVolumeNameUserInfoKey`](/documentation/AppKit/NSWorkspace/localizedVolumeNameUserInfoKey)

A string containing the user-visible name of the volume.

[`volumeURLUserInfoKey`](/documentation/AppKit/NSWorkspace/volumeURLUserInfoKey)

A URL containing the mount path of the volume.

[`oldLocalizedVolumeNameUserInfoKey`](/documentation/AppKit/NSWorkspace/oldLocalizedVolumeNameUserInfoKey)

A string containing the old user-visible name of the volume

[`oldVolumeURLUserInfoKey`](/documentation/AppKit/NSWorkspace/oldVolumeURLUserInfoKey)

A URL containing the old mount path of the volume

### Deprecated

[Deprecated Symbols](/documentation/AppKit/nsworkspace-deprecated-symbols)

Review unsupported symbols and their replacements.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)