Inherits from | |
Conforms to | |
Framework | /System/Library/Frameworks/AppKit.framework |
Availability | Available in Mac OS X v10.0 and later. |
Companion guide | |
Declared in | NSWorkspace.h |
Related sample code |
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
Launching applications
There is one shared NSWorkspace
object per application. You use the class method sharedWorkspace
to access it. For example, the following statement uses an NSWorkspace
object to request that a file be opened in the TextEdit application:
[[NSWorkspace sharedWorkspace] openFile:@"/Myfiles/README" |
withApplication:@"TextEdit"]; |
– openFile:
– openFile:withApplication:
– openFile:fromImage:at:inView:
– openFile:withApplication:andDeactivate:
– openTempFile:
– openURL:
– typeOfFile:error:
– localizedDescriptionForType:
– preferredFilenameExtensionForType:
– fileNameExtension:isValidForType:
– type:conformsToType:
– iconForFile:
– iconForFileType:
– iconForFiles:
– getInfoForFile:application:type:
– fullPathForApplication:
– getFileSystemInfoForPath:isRemovable:isWritable:isUnmountable:description:type:
– isFilePackageAtPath:
– activeApplication
– launchedApplications
– absolutePathForAppBundleWithIdentifier:
– launchAppWithBundleIdentifier:options:additionalEventParamDescriptor:launchIdentifier:
– openURLs:withAppBundleIdentifier:options:additionalEventParamDescriptor:launchIdentifiers:
Returns the shared NSWorkspace
instance.
+ (NSWorkspace *)sharedWorkspace
The NSWorkspace
object associated with the process.
NSWorkspace.h
Returns the absolute file-system path of an application bundle.
- (NSString *)absolutePathForAppBundleWithIdentifier:(NSString *)bundleIdentifier
The bundle identifier string. This value corresponds to the value in the CFBundleIdentifier
key of the application’s Info.plist
file. For example, the bundle identifier of the TextEdit application is com.apple.TextEdit
.
The file system path to the application bundle identified by bundleIdentifier, or nil
if the bundle cannot be found.
NSWorkspace.h
Returns a dictionary with information about the current active application.
- (NSDictionary *)activeApplication
A dictionary with information about the application. The dictionary contains as many of the keys described in “Constants” as are available.
NSWorkspace.h
Polls the system’s drives for any disks that have been inserted but not yet mounted.
- (void)checkForRemovableMedia
This method doesn’t wait until such disks are mounted; instead, it requests that the disk be mounted asynchronously and returns immediately. Currently has no effect.
NSWorkspace.h
Requests the system wait for the specified amount of time before turning off the power or logging out the user.
- (NSInteger)extendPowerOffBy:(NSInteger)requested
The number of milliseconds to wait before turning off the power or logging off the user.
The number of milliseconds granted by the system.
Currently unimplemented.
NSWorkspace.h
Returns whether the specified filename extension is appropriate for the Uniform Type Identifier.
- (BOOL)filenameExtension:(NSString *)filenameExtension isValidForType:(NSString *)typeName
A string containing the filename extension.
A string containing the Uniform Type Identifier.
YES
if fileNameExtension is a valid extension for typeName, NO
otherwise
Returns a Boolean value indicating whether a change to the file system has been registered with a noteFileSystemChanged
message since the last fileSystemChanged
message.
- (BOOL)fileSystemChanged
Currently, this method always returns NO
.
NSWorkspace.h
Examines all applications and updates the records of registered services and file types.
- (void)findApplications
NSWorkspace.h
Returns the full path for the specified application.
- (NSString *)fullPathForApplication:(NSString *)appName
The name of the application.
The full path for the application, or nil
if the specified application was not found.
NSWorkspace.h
Describes the file system at fullPath.
- (BOOL)getFileSystemInfoForPath:(NSString *)fullPath isRemovable:(BOOL *)removableFlag isWritable:(BOOL *)writableFlag isUnmountable:(BOOL *)unmountableFlag description:(NSString **)description type:(NSString **)fileSystemType
The path to the file-system mount point.
On input, a boolean variable; on return, this variable contains YES
if the file system is on removable media.
On input, a boolean variable; on return, this variable contains YES
if the file system writable.
On input, a boolean variable; on return, this variable contains YES
if the file system is unmountable.
On input, a pointer to a string object variable; on return, if the method was successful, this variable contains a string object that describes the file system. You should not rely on this description for program logic but can use it in message strings. Values can include “hard,” “nfs,” and “foreign."
On input, a pointer to a string object variable; on return, if the method was successful, this variable contains the file-system type. Values can include “HFS,” “UFS,” or other values.
YES
if the information was successfully returned, otherwise NO
.
NSWorkspace.h
Retrieves information about the specified file.
- (BOOL)getInfoForFile:(NSString *)fullPath application:(NSString **)appName type:(NSString **)type
The full path to the desired file.
The application the system would use to open the file.
On input, a pointer to a string object variable; on return, if the method is successful, this variable contains a string object with the filename extension or encoded HFS file type of the file.
YES
if the information was retrieved successfully; otherwise, NO
if the file could not be found or the application was not associated with the file.
NSWorkspace.h
Hides all applications other than the sender.
- (void)hideOtherApplications
The user can hide all applications except the current one by Command-Option-clicking on an application’s Dock icon.
NSWorkspace.h
Returns an image containing the icon for the specified file.
- (NSImage *)iconForFile:(NSString *)fullPath
The full path to the file.
The icon associated with the file.
The returned image has an initial size of 32 pixels by 32 pixels.
NSWorkspace.h
Returns an image containing the icon for the specified files.
- (NSImage *)iconForFiles:(NSArray *)fullPaths
An array of NSString
objects, each of which contains the full path to a file.
The icon associated with the group of files.
If fullPaths specifies one file, that file's icon is returned. If fullPaths specifies more than one file, an icon representing the multiple selection is returned.
NSWorkspace.h
Returns an image containing the icon for files of the specified type.
- (NSImage *)iconForFileType:(NSString *)fileType
The file type, which may be either a filename extension or an encoded HFS file type.
The icon associated with files of the given type.
The returned image has an initial size of 32 pixels by 32 pixels.
NSWorkspace.h
Determines whether the specified path is a file package.
- (BOOL)isFilePackageAtPath:(NSString *)fullPath
The full path to examine.
YES
if the path identifies a file package; otherwise, NO
if the path does not exist, is not a directory, or is not a file package.
NSWorkspace.h
Launches the specified application.
- (BOOL)launchApplication:(NSString *)appName
The name of the application to open.
YES
if the application was successfully launched or was already running; otherwise, NO
.
The appName parameter need not be specified with a full path and, in the case of an application wrapper, may be specified with or without the .app
extension, as described in “Use of .app Extension”.
Before this method begins, it posts an NSWorkspaceWillLaunchApplicationNotification
to the NSWorkspace
object’s notification center. When the operation is complete, it posts an NSWorkspaceDidLaunchApplicationNotification
.
NSWorkspace.h
Launches the specified application using additional options.
- (BOOL)launchApplication:(NSString *)appName showIcon:(BOOL)showIcon autolaunch:(BOOL)autolaunch
The name of the application to open.
If NO
, the application's icon is not placed on the screen. (The icon still exists, though.)
If YES
, the autolaunch default is set as though the specified application were autolaunched at startup.
YES
if the application was successfully launched or was already running; otherwise, NO
.
This method is provided to enable daemon-like applications that lack a normal user interface. Its use is not generally encouraged.
Returns YES
if the application is successfully launched or already running, and NO
if it can’t be launched.
Before this method begins, it posts an NSWorkspaceWillLaunchApplicationNotification
to the NSWorkspace
object’s notification center. When the operation is complete, it posts an NSWorkspaceDidLaunchApplicationNotification
.
NSWorkspace.h
Launches the application corresponding to the specified bundleIdentifier.
- (BOOL)launchAppWithBundleIdentifier:(NSString *)bundleIdentifier options:(NSWorkspaceLaunchOptions)options additionalEventParamDescriptor:(NSAppleEventDescriptor *)descriptor launchIdentifier:(NSNumber **)identifier
A bundle identifier string. This value corresponds to the value in the CFBundleIdentifier
key of the application’s Info.plist
file. For example, the bundle identifier of the TextEdit application is com.apple.TextEdit
.
Options to use when launching the application. Values for this parameter are described in “Constants.”
Additional options specified in an AppleEvent-style descriptor. For example, you could use this parameter to specify additional documents to open when the application is launched.
On input, a pointer to a number object variable. On return, the variable contains a number object with a unique identifier for the launch attempt. You can use this value to distinguish individual launch requests. This parameter may be nil
.
YES
if the application was found and launched; otherwise, NO
.
NSWorkspace.h
Returns an array of dictionaries, one entry for each running application.
- (NSArray *)launchedApplications
An array of NSDictionary
objects. Each dictionary contains as many of the keys described in “Constants” as are available.
NSWorkspace.h
Returns the localized description for the specified Uniform Type Identifier
- (NSString *)localizedDescriptionForType:(NSString *)typeName
A string containing the Uniform Type Identifier.
An NSString containg the localized description of typeName.
The localized description is suitable for displaying to the user.
NSWorkspace.h
Returns the mount points of all local volumes, not just the removable ones returned by mountedRemovableMedia
.
- (NSArray *)mountedLocalVolumePaths
An array of NSString
objects, each of which contains the full pathname of the mount point for any local volumes.
NSWorkspace.h
Returns the full pathnames of all currently mounted removable disks.
- (NSArray *)mountedRemovableMedia
An array of NSString
objects, each of which contains the full pathname of a mounted removable disk.
If the computer provides an interrupt or other notification when the user inserts a disk into a drive, the Finder will mount the disk immediately. However, if no notification is given, the Finder won’t be aware that a disk needs to be mounted. On such systems, an application should invoke either mountNewRemovableMedia
or checkForRemovableMedia
before invoking mountedRemovableMedia
. Either of these methods cause the Finder to poll the drives to see if a disk is present. If a disk has been inserted but not yet mounted, these methods will cause the Finder to mount it.
The Disk button in an Open or Save panel invokes mountedRemovableMedia
and mountNewRemovableMedia
as part of its operation, so most applications won’t need to invoke these methods directly.
NSWorkspace.h
Returns the full pathnames of any newly mounted disks.
- (NSArray *)mountNewRemovableMedia
An array of NSString objects, each of which contains the full pathname to a newly mounted disk.
This method polls the system’s drives for any disks that have been inserted but not yet mounted and waits until the new disks have been mounted. This method posts an NSWorkspaceDidMountNotification
to the NSWorkspace
object’s notification center when it is finished. Currently provides the same functionality as mountedRemovableMedia
.
NSWorkspace.h
Informs the NSWorkspace
object that the file system has changed.
- (void)noteFileSystemChanged
The NSWorkspace
object then gets the status of all the files and directories it is interested in and updates itself appropriately. This method is used by many objects that write or delete files.
The NSDocument
and NSSavePanel
objects use this method when saving a file. If you create a file directly, you should call noteFileSystemChanged
so that the Finder can update the folder if it is open.
NSWorkspace.h
Informs the NSWorkspace
object that the file system changed at the specified path.
- (void)noteFileSystemChanged:(NSString *)path
The full path that changed.
The NSWorkspace
object then gets the status of all the files and directories it is interested in and updates itself appropriately. This method is used by many objects that write or delete files.
NSWorkspace.h
Informs the NSWorkspace
object that the defaults database has changed.
- (void)noteUserDefaultsChanged
The NSWorkspace
object then reads all the defaults it is interested in and reconfigures itself appropriately. For example, this method is used by the Preferences application to notify the Finder whether the user prefers to see hidden files. Currently has no effect.
NSWorkspace.h
Returns the notification center for workspace notifications.
- (NSNotificationCenter *)notificationCenter
The notification center object.
NSWorkspace.h
Opens the specified file specified using the default application associated with its type.
- (BOOL)openFile:(NSString *)fullPath
The full path to the file.
YES
if the file was successfully opened; otherwise, NO
.
The sending application is deactivated before the request is sent.
– openFile:fromImage:at:inView:
– openFile:withApplication:
– openFile:withApplication:andDeactivate:
– openTempFile:
NSWorkspace.h
Opens a file using the default application for its type and animates the action using a custom icon.
- (BOOL)openFile:(NSString *)fullPath fromImage:(NSImage *)anImage at:(NSPoint)point inView:(NSView *)aView
The full path to the file.
The icon for the file.
The point in aView
at which to display the icon.
The view in which to display the icon.
YES
if the file was successfully opened; otherwise, NO
.
The Finder provides an animation before opening the file to give the user feedback that the file is to be opened. To provide this animation, anImage should contain an icon for the file, and its image should be displayed at point, specified in the coordinates of aView. Currently provides the same functionality as openFile:
.
The sending application is deactivated before the request is sent.
NSWorkspace.h
Opens a file using the specified application.
- (BOOL)openFile:(NSString *)fullPath withApplication:(NSString *)appName
The full path to the file.
The name of the application to use when opening the file.
YES
if the file was successfully opened; otherwise, NO
.
The appName parameter need not be specified with a full path and, in the case of an application wrapper, may be specified with or without the .app
extension, as described in “Use of .app Extension”. The sending application is deactivated before the request is sent.
NSWorkspace.h
Opens the specified file and optionally deactivates the sending application.
- (BOOL)openFile:(NSString *)fullPath withApplication:(NSString *)appName andDeactivate:(BOOL)flag
The full path to the file.
The name of the application to use when opening the file.
If YES, the sending application is deactivated before the request is sent, allowing the opening application to become the active application.
YES
if the file was successfully opened; otherwise, NO
.
The appName parameter need not be specified with a full path and, in the case of an application wrapper, may be specified with or without the .app
extension, as described in “Use of .app Extension”. If appName is nil
, the default application for the file’s type is used.
– openFile:
– openFile:withApplication:
– application:openFile:
(NSApplication delegate method)NSWorkspace.h
Opens the specified temporary file using the default application for its type.
- (BOOL)openTempFile:(NSString *)fullPath
The full path to the temporary file.
YES
if the file was successfully opened; otherwise, NO
.
The sending application is deactivated before the request is sent. Using this method instead of one of the openFile:...
methods lets the receiving application know that it should delete the file when it no longer needs it. Currently provides the same functionality as openFile:
.
– openFile:
– openFile:fromImage:at:inView:
– openFile:withApplication:
– openFile:withApplication:andDeactivate:
NSWorkspace.h
Opens the location at the specified URL.
- (BOOL)openURL:(NSURL *)url
A URL specifying the location to open.
YES
if the location was successfully opened; otherwise, NO
.
NSWorkspace.h
Opens one or more files from an array of URLs.
- (BOOL)openURLs:(NSArray *)urls withAppBundleIdentifier:(NSString *)bundleIdentifier options:(NSWorkspaceLaunchOptions)options additionalEventParamDescriptor:(NSAppleEventDescriptor *)descriptor launchIdentifiers:(NSArray **)identifiers
An array of NSURL
objects, each one identifying a URL for the application to open.
A bundle identifier string or nil
to use the default system bindings. This value corresponds to the value in the CFBundleIdentifier
key of the application’s Info.plist
file. For example, the bundle identifier of the TextEdit application is com.apple.TextEdit
.
Options to use when launching the application. Values for this parameter are described in “Constants.”
Additional options specified in an AppleEvent-style descriptor. For example, you could use this parameter to specify additional documents to open when the application is launched.
On input, a pointer to an array object variable. On return, the variable contains an array of NSNumber objects. Each number object contains a unique identifier (one for each URL) for the launch attempt. You can use these values to distinguish individual launch requests. This parameter may be nil
.
YES
if the application was found and launched; otherwise, NO
.
NSWorkspace.h
Performs a file operation on a set of files in a particular directory.
- (BOOL)performFileOperation:(NSString *)operation source:(NSString *)source destination:(NSString *)destination files:(NSArray *)files tag:(NSInteger *)tag
The file operation to perform. The possible values for this parameter are described in “Constants.”
The full path to the directory containing the files on which to operate.
The full path to the destination directory of the operation.
An array of NSString
objects specifying the names of the files and directories to be manipulated. Each string must not contain any path information other than the name of the file or directory. In other words, all of the files and directories must be located in the source directory and not in one if its subdirectories.
On input, a integer variable; on return, this variable contains a negative integer if the operation fails, 0 if the operation was performed synchronously and succeeded, or a positive integer if the operation was performed asynchronously. If the value is a positive integer, the value is a tag that identifies the requested file operation.
YES
if the operation succeeded; otherwise, NO
.
Some operations—such as moving, copying, and linking files—require a destination directory to be specified. If not, destination should be the empty string (@""
). Before this method returns, it posts an NSWorkspaceDidPerformFileOperationNotification
to the NSWorkspace
object's notification center.
NSWorkspace.h
Returns the preferred filename extension for the specified Uniform Type Identifier.
- (NSString *)preferredFilenameExtensionForType:(NSString *)typeName
A string containing the Uniform Type Identifier.
The appropriate filename extension for typeName, or nil
if no extension could be determined.
NSWorkspace.h
Selects the file specified by fullPath.
- (BOOL)selectFile:(NSString *)fullPath inFileViewerRootedAtPath:(NSString *)rootFullPath
The full path of the file to select.
If a path is specified, a new file viewer is opened. If you specify an empty string (@""
) for this parameter, the file is selected in the main viewer.
YES
if the file was successfully selected; otherwise, NO
.
NSWorkspace.h
Sets the icon for the file or directory at the specified path.
- (BOOL)setIcon:(NSImage *)image forFile:(NSString *)fullPath options:(NSWorkspaceIconCreationOptions)options
The image to use as the icon for the file or directory.
The full path of the file or directory.
The icon representations to generate from the image. You specify this value by combining the appropriate NSWorkspaceIconCreationOptions
constants, listed in “Constants,” using the C bitwise OR
operator. Specify 0
if you want to generate icons in all available icon representation formats.
YES
if the icon was set; otherwise, NO
.
The image can be an arbitrary image, with or without transparency. This image is automatically scaled (as needed) to generate the icon representations. The file or folder must exist and be writable by the user.
It is recommended that applications include the NSExclude10_4ElementsIconCreationOption
option for compatibility with pre-Mac OS X v10.3 Finder. Icons that include the high resolution elements prevent custom icons from being displayed on earlier systems.
NSWorkspace.h
Animates a sliding image from one point to another.
- (void)slideImage:(NSImage *)image from:(NSPoint)fromPoint to:(NSPoint)toPoint
The image to animate.
The starting point, in screen coordinates.
The ending point, in screen coordinates.
Currently unimplemented.
NSWorkspace.h
Returns a Boolean indicating that the first Uniform Type Identifier conforms to the second Uniform Type Identifier.
- (BOOL)type:(NSString *)firstTypeName conformsToType:(NSString *)secondTypeName
A string containing the Uniform Type Identifier that should conform to secondTypeName.
A string containing a Uniform Type Identifier.
YES
if firstTypeName conforms to the uniform type identifier hierarchy of secondTypeName, NO
otherwise.
Use this method instead of comparing Uniform Identifier Types for equality. See Uniform Type Identifiers Overview for information about Uniform Type Identifier conformance.
This method will always return YES
if the two strings are equal. It is appropriate to use this method with other type names, including those declared in CFBundleTypeName
Info.plist
entries.
NSWorkspace.h
Returns the uniform type identifier of the specified file, if it can be determined..
- (NSString *)typeOfFile:(NSString *)absoluteFilePath error:(NSError **)outError
The absolute path of the file.
If the Uniform Type Identifier of the file at absolutePath can’t be determined, outError contains an NSError object that describing why.
An NSString
containing the uniform type identifier of the file at absoluteFilePath
. If no UTI can be determined the return value is nil
.
If the file at the specified path is a symbolic link, the type of the symbolic link is returned.
NSWorkspace.h
Unmounts and ejects the device at the specified path.
- (BOOL)unmountAndEjectDeviceAtPath:(NSString *)path
The path to the device.
YES
if the device was unmounted; otherwise, NO
.
When this method begins, it posts an NSWorkspaceWillUnmountNotification
to the NSWorkspace
object’s notification center. When it is finished, it posts an NSWorkspaceDidUnmountNotification
.
NSWorkspace.h
Returns a Boolean value indicating whether a change to the defaults database has been registered with a noteUserDefaultsChanged
message since the last userDefaultsChanged
message.
- (BOOL)userDefaultsChanged
Currently, this method always returns NO
.
NSWorkspace.h
The following table describes keys for an NSDictionary
object containing information about an application. This dictionary is returned by activeApplication
and launchedApplications
, and is also provided in the userInfo of NSWorkspace
notifications for application launch and termination.
Key |
Value |
---|---|
|
The full path to the application, as a |
|
The application's name, as an |
|
The application’s bundle identifier, as an |
|
The application'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 |
These constants specify different types of files returned by getInfoForFile:application:type:
.
NSString *NSPlainFileType; NSString *NSDirectoryFileType; NSString *NSApplicationFileType; NSString *NSFilesystemFileType; NSString *NSShellCommandFileType;
NSPlainFileType
Plain (untyped) file
Available in Mac OS X v10.0 and later.
Declared in NSWorkspace.h
.
NSDirectoryFileType
Directory
Available in Mac OS X v10.0 and later.
Declared in NSWorkspace.h
.
NSApplicationFileType
Cocoa application
Available in Mac OS X v10.0 and later.
Declared in NSWorkspace.h
.
NSFilesystemFileType
File-system mount point
Available in Mac OS X v10.0 and later.
Declared in NSWorkspace.h
.
NSShellCommandFileType
Executable shell command
Available in Mac OS X v10.0 and later.
Declared in NSWorkspace.h
.
NSWorkspace.h
These constants specify different types of file operations used by performFileOperation:source:destination:files:tag:
.
NSString *NSWorkspaceMoveOperation; NSString *NSWorkspaceCopyOperation; NSString *NSWorkspaceLinkOperation; NSString *NSWorkspaceCompressOperation; NSString *NSWorkspaceDecompressOperation; NSString *NSWorkspaceEncryptOperation; NSString *NSWorkspaceDecryptOperation; NSString *NSWorkspaceDestroyOperation; NSString *NSWorkspaceRecycleOperation; NSString *NSWorkspaceDuplicateOperation;
NSWorkspaceMoveOperation
Move file to destination. Behaves the same as movePath:toPath:handler:
.
Available in Mac OS X v10.0 and later.
Declared in NSWorkspace.h
.
NSWorkspaceCopyOperation
Copy file to destination. Behaves the same as copyPath:toPath:handler:
.
Available in Mac OS X v10.0 and later.
Declared in NSWorkspace.h
.
NSWorkspaceLinkOperation
Create hard link to file in destination. Behaves the same as linkPath:toPath:handler:
.
Available in Mac OS X v10.0 and later.
Declared in NSWorkspace.h
.
NSWorkspaceCompressOperation
Compress file. This operation always returns an error.
Available in Mac OS X v10.0 and later.
Declared in NSWorkspace.h
.
NSWorkspaceDecompressOperation
Decompress file. This operation always returns an error.
Available in Mac OS X v10.0 and later.
Declared in NSWorkspace.h
.
NSWorkspaceEncryptOperation
Encrypt file. This operation always returns an error.
Available in Mac OS X v10.0 and later.
Declared in NSWorkspace.h
.
NSWorkspaceDecryptOperation
Decrypt file. This operation always returns an error.
Available in Mac OS X v10.0 and later.
Declared in NSWorkspace.h
.
NSWorkspaceDestroyOperation
Destroy file. Behaves the same as removeFileAtPath:handler:
.
Available in Mac OS X v10.0 and later.
Declared in NSWorkspace.h
.
NSWorkspaceRecycleOperation
Move file to trash. The file is moved to the trash folder on the volume containing the file using the same semantics as NSWorkspaceMoveOperation
. If a file with the same name currently exists in the trash folder, the new file is renamed. If no trash folder exists on the volume containing the file, the operation fails.
Available in Mac OS X v10.0 and later.
Declared in NSWorkspace.h
.
NSWorkspaceDuplicateOperation
Duplicate file in source directory.
Available in Mac OS X v10.0 and later.
Declared in NSWorkspace.h
.
NSWorkspace.h
Constants representing different launch options.
typedef unsigned int NSWorkspaceLaunchOptions;
See “Launch Options”
for possible values.
NSWorkspace.h
These constants define launch options you can pass to launchAppWithBundleIdentifier:options:additionalEventParamDescriptor:launchIdentifier:
and openURLs:withAppBundleIdentifier:options:additionalEventParamDescriptor:launchIdentifiers:
.
enum { NSWorkspaceLaunchAndPrint = 0x00000002, NSWorkspaceLaunchInhibitingBackgroundOnly = 0x00000080, NSWorkspaceLaunchWithoutAddingToRecents = 0x00000100, NSWorkspaceLaunchWithoutActivation = 0x00000200, NSWorkspaceLaunchAsync = 0x00010000, NSWorkspaceLaunchAllowingClassicStartup = 0x00020000, NSWorkspaceLaunchPreferringClassic = 0x00040000, NSWorkspaceLaunchNewInstance = 0x00080000, NSWorkspaceLaunchAndHide = 0x00100000, NSWorkspaceLaunchAndHideOthers = 0x00200000, NSWorkspaceLaunchDefault = NSWorkspaceLaunchAsync | NSWorkspaceLaunchAllowingClassicStartup };
NSWorkspaceLaunchAndPrint
Print items instead of opening them.
Available in Mac OS X v10.3 and later.
Declared in NSWorkspace.h
.
NSWorkspaceLaunchInhibitingBackgroundOnly
Causes launch to fail if the target is background-only.
Available in Mac OS X v10.3 and later.
Declared in NSWorkspace.h
.
NSWorkspaceLaunchWithoutAddingToRecents
Do not add the application or documents to the Recents menu.
Available in Mac OS X v10.3 and later.
Declared in NSWorkspace.h
.
NSWorkspaceLaunchWithoutActivation
Launch the application but do not bring it into the foreground.
Available in Mac OS X v10.3 and later.
Declared in NSWorkspace.h
.
NSWorkspaceLaunchAsync
Launch the application and return the results asynchronously.
Available in Mac OS X v10.3 and later.
Declared in NSWorkspace.h
.
NSWorkspaceLaunchAllowingClassicStartup
Start up the Classic compatibility environment, if it is required by the application.
Available in Mac OS X v10.3 and later.
Declared in NSWorkspace.h
.
NSWorkspaceLaunchPreferringClassic
Force the application to launch in the Classic compatibility environment.
Available in Mac OS X v10.3 and later.
Declared in NSWorkspace.h
.
NSWorkspaceLaunchNewInstance
Create a new instance of the application, even if one is already running.
Available in Mac OS X v10.3 and later.
Declared in NSWorkspace.h
.
NSWorkspaceLaunchAndHide
Tell the application to hide itself as soon as it has finished launching.
Available in Mac OS X v10.3 and later.
Declared in NSWorkspace.h
.
NSWorkspaceLaunchAndHideOthers
Hide all applications except the newly launched one.
Available in Mac OS X v10.3 and later.
Declared in NSWorkspace.h
.
NSWorkspaceLaunchDefault
Launch the application asynchronously and launch it in the Classic environment, if required.
Available in Mac OS X v10.3 and later.
Declared in NSWorkspace.h
.
NSWorkspace.h
These constants describe the NSWorkspaceIconCreationOptions
values used by setIcon:forFile:options:
.
enum { NSExcludeQuickDrawElementsIconCreationOption = 1 << 1, NSExclude10_4ElementsIconCreationOption = 1 << 2 };
NSExcludeQuickDrawElementsIconCreationOption
Suppress generation of the QuickDraw format icon representations that are used Mac OS X v10.0 through v10.4.
Available in Mac OS X v10.4 and later.
Declared in NSWorkspace.h
.
NSExclude10_4ElementsIconCreationOption
Suppress generation of the new higher resolution icon representations that are supported in Mac OS X v10.4.
Available in Mac OS X v10.4 and later.
Declared in NSWorkspace.h
.
You can combine these using the C bitwise OR operator.
NSWorkspace.h
All NSWorkspace
notifications are posted to the NSWorkspace
object’s own notification center, not the application’s default notification center. Access this center using the NSWorkspace
object’s notificationCenter
method.
Posted when a new application has started up.
The notification object is the shared NSWorkspace
instance. The userInfo dictionary contains the keys and values described in “Constants.”
NSWorkspace.h
Posted when a new device has been mounted.
The notification object is the shared NSWorkspace
instance. The userInfo dictionary contains the following information:
Key |
Value |
---|---|
|
The path where the device was mounted, as a string. |
NSWorkspace.h
Posted when a file operation has been performed in the receiving application.
The notification object is the shared NSWorkspace
instance. The userInfo dictionary contains the following information:
Key |
Value |
---|---|
|
An |
NSWorkspace.h
Posted when an application finishes executing.
The notification object is the shared NSWorkspace
instance. The userInfo dictionary contains the keys and values described in “Constants.”
NSWorkspace.h
Posted when the machine wakes from sleep.
The notification object is the shared NSWorkspace
instance. The notification does not contain a userInfo dictionary.
NSWorkspace.h
Posted when the Finder has unmounted a device.
The notification object is the shared NSWorkspace
instance. The userInfo dictionary contains the following information:
Key |
Value |
---|---|
|
The path where the device was previously mounted, as an |
NSWorkspace.h
Posted after a user session is switched in. This allows an application to re-enable some processing when a switched out session gets switched back in, for example.
The notification object is the shared NSWorkspace
instance. The notification does not contain a userInfo dictionary.
NSWorkspace.h
Posted before a user session is switched out. This allows an application to disable some processing when its user session is switched out, and re-enable when that session gets switched back in, for example.
The notification object is the shared NSWorkspace
instance. The notification does not contain a userInfo dictionary.
If an application is launched in an inactive session, NSWorkspaceSessionDidResignActiveNotification
is sent after NSApplicationWillFinishLaunchingNotification
and before sending NSApplicationDidFinishLaunchingNotification
.
NSWorkspace.h
Posted when the Finder is about to launch an application.
The notification object is the shared NSWorkspace
instance. The userInfo dictionary contains the keys and values described in “Constants.”
NSWorkspace.h
Posted when the user has requested a logout or that the machine be powered off.
The notification object is the shared NSWorkspace
instance. This notification does not contain a userInfo dictionary.
NSWorkspace.h
Posted before the machine goes to sleep. An observer of this message can delay sleep for up to 30 seconds while handling this notification.
The notification object is the shared NSWorkspace
instance. The notification does not contain a userInfo dictionary.
NSWorkspace.h
Posted when the Finder is about to unmount a device. This notification will not be delivered if a volume was forcibly and immediately made unavailable, such as when a FireWire drive is simply unplugged, because there is no chance to deliver it before the volume becomes unavailable.
The notification object is the shared NSWorkspace
instance. The userInfo dictionary contains the following information:
Key |
Value |
---|---|
|
The path where the device is mounted, as a string. |
NSWorkspace.h
© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-04-27)