NSWorkspace
A workspace that can launch other apps and perform a variety of file-handling services.
Declaration
class NSWorkspaceMentioned in
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:
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
Accessing the Workspace Notification Center
Opening URLs
open(_:configuration:completionHandler:)open(_:withApplicationAt:configuration:completionHandler:)open(_:)
Launching and Hiding Apps
Managing Open Configurations
Manipulating Files
duplicate(_:completionHandler:)recycle(_:completionHandler:)activateFileViewerSelecting(_:)selectFile(_:inFileViewerRootedAtPath:)
Manipulating Uniform Type Identifier Information
type(ofFile:)localizedDescription(forType:)preferredFilenameExtension(forType:)filenameExtension(_:isValidForType:)type(_:conformsToType:)
Requesting Information
urlForApplication(toOpen:)urlForApplication(toOpen:)urlForApplication(withBundleIdentifier:)urlsForApplications(toOpen:)urlsForApplications(toOpen:)urlsForApplications(withBundleIdentifier:)getFileSystemInfo(forPath:isRemovable:isWritable:isUnmountable:description:type:)isFilePackage(atPath:)frontmostApplicationrunningApplicationsmenuBarOwningApplicationgetInfoForFile(_:application:type:)
Setting Default Application Information
setDefaultApplication(at:toOpenFileAt:completion:)setDefaultApplication(at:toOpen:completion:)setDefaultApplication(at:toOpenContentTypeOfFileAt:completion:)setDefaultApplication(at:toOpenURLsWithScheme:completion:)
Managing Icons
Unmounting a Device
Managing the Desktop Image
desktopImageURL(for:)setDesktopImageURL(_:for:options:)desktopImageOptions(for:)NSWorkspace.DesktopImageOptionKey
Performing Finder Spotlight Searches
Finder File Labels
Tracking Changes to the File System
Requesting Additional Time Before Logout
Supporting Accessibility
accessibilityDisplayShouldDifferentiateWithoutColoraccessibilityDisplayShouldIncreaseContrastaccessibilityDisplayShouldReduceTransparencyaccessibilityDisplayShouldInvertColorsaccessibilityDisplayShouldReduceMotionisSwitchControlEnabledisVoiceOverEnabled
Performing Privileged Operations
Responding to Environment Notifications
willLaunchApplicationNotificationdidLaunchApplicationNotificationdidTerminateApplicationNotificationsessionDidBecomeActiveNotificationsessionDidResignActiveNotificationdidHideApplicationNotificationdidUnhideApplicationNotificationdidActivateApplicationNotificationdidDeactivateApplicationNotificationdidRenameVolumeNotificationdidMountNotificationwillUnmountNotificationdidUnmountNotificationdidChangeFileLabelsNotificationactiveSpaceDidChangeNotificationdidWakeNotificationwillPowerOffNotificationwillSleepNotificationscreensDidSleepNotificationscreensDidWakeNotificationaccessibilityDisplayOptionsDidChangeNotificationlocalizedVolumeNameUserInfoKeyvolumeURLUserInfoKeyoldLocalizedVolumeNameUserInfoKeyoldVolumeURLUserInfoKey
Deprecated
Structures
NSWorkspace.AccessibilityDisplayOptionsDidChangeMessageNSWorkspace.ActiveSpaceDidChangeMessageNSWorkspace.DidActivateApplicationMessageNSWorkspace.DidChangeFileLabelsMessageNSWorkspace.DidDeactivateApplicationMessageNSWorkspace.DidHideApplicationMessageNSWorkspace.DidLaunchApplicationMessageNSWorkspace.DidMountVolumeMessageNSWorkspace.DidRenameVolumeMessageNSWorkspace.DidTerminateApplicationMessageNSWorkspace.DidUnhideApplicationMessageNSWorkspace.DidUnmountVolumeMessageNSWorkspace.DidWakeMessageNSWorkspace.ScreensDidSleepMessageNSWorkspace.ScreensDidWakeMessageNSWorkspace.SessionDidBecomeActiveMessageNSWorkspace.SessionDidResignActiveMessageNSWorkspace.WillLaunchApplicationMessageNSWorkspace.WillSleepMessageNSWorkspace.WillUnmountVolumeMessage