Platforms to show: All Mac Windows Linux Cross-Platform
Back to NSWorkspaceMBS class.
NSWorkspaceMBS.absolutePathForAppBundleWithIdentifier(bundleIdentifier as string) as string
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 12.5 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
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.
Returns the file system path to the application bundle identified by bundleIdentifier, or "" if the bundle cannot be found.
NSWorkspaceMBS.activateFileViewerSelectingFiles(Files() as folderitem)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 11.3 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Available in Mac OS X v10.6 and later.
NSWorkspaceMBS.activateFileViewerSelectingURLs(URLs() as string)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 11.3 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Available in Mac OS X v10.6 and later.
NSWorkspaceMBS.ApplicationsToOpenFile(File as FolderItem) as FolderItem() New in 26.1
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 26.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Returns an array of files to available apps that can open the specified url. Returns an empty array if no app can open the file, or if the file doesn’t exist.
The system sorts the resulting array according to each app’s suitability to open the URL. The returned array lists the best match first.
NSWorkspaceMBS.ApplicationsToOpenURL(url as string) as FolderItem() New in 26.1
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 26.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Returns an array of URLs to available apps that can open the specified url. Returns an empty array if no app can open the URL, or if the file URL doesn’t exist.
The system sorts the resulting array according to each app’s suitability to open the URL. The returned array lists the best match first.
NSWorkspaceMBS.ApplicationsWithBundleIdentifier(bundleIdentifier as string) as FolderItem() New in 26.1
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 26.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Returns an array of URLs to available apps that can open the specified bundleIdentifier.
Returns an empty array if no app associates with the bundle identifier.
The system sorts the resulting array accounts according to each app’s suitability to launch. The returned array lists the best match first.
NSWorkspaceMBS.ApplicationToOpenFile(File as FolderItem) as FolderItem New in 26.1
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 26.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Returns the FolderItem of the default app that would open the specified url. Returns nil if no app can open the FolderItem, or if the file does not exist.
This method is the programmatic equivalent of double-clicking a document in the Finder.
You can safely call this method from any thread of your app.
NSWorkspaceMBS.ApplicationToOpenURL(url as String) as FolderItem New in 26.1
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 26.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Returns the URL of the default app that would open the specified url. Returns nil if no app can open the URL, or if the file URL does not exist.
This method is the programmatic equivalent of double-clicking a document in the Finder.
You can safely call this method from any thread of your app.
NSWorkspaceMBS.ApplicationWithBundleIdentifier(bundleIdentifier as String) as FolderItem New in 26.1
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 26.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Returns the URL of the app, or nil if no app has the bundle identifier.
This method uses various heuristics in case multiple apps have the same bundle ID.
You can safely call this method from any thread of your app.
NSWorkspaceMBS.desktopImageOptionsForScreen(screen as NSScreenMBS) as dictionary
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 11.3 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
screen: The screen for which to get the desktop image options.
Returns a dictionary containing key-value pairs. Keys can be NSWorkspaceDesktopImageScalingKey, NSWorkspaceDesktopImageAllowClippingKey or NSWorkspaceDesktopImageFillColorKey.
Available in Mac OS X v10.6 and later.
NSWorkspaceMBS.desktopImageURLForScreen(screen as NSScreenMBS) as folderitem
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 11.3 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
screen: The screen for which to get the desktop image.
Returns the desktop image.
Available in Mac OS X v10.6 and later.
NSWorkspaceMBS.fileLabelColors as NSColorMBS()
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 11.3 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
This array has the same number of elements as fileLabels, and the color at a given index corresponds to the label at the same index.
You can listen for notifications named NSWorkspaceDidChangeFileLabelsNotification to be notified when file labels change which may result in changes to the order of the fileLabelColors.
Available in Mac OS X v10.6 and later.
NSWorkspaceMBS.fileLabels as string()
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 11.3 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
You can listen for notifications named NSWorkspaceDidChangeFileLabelsNotification to be notified when file labels change.
Available in Mac OS X v10.6 and later.
NSWorkspaceMBS.findApplications
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 8.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
NSWorkspaceMBS.frontmostApplication as NSRunningApplicationMBS
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 11.3 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Requires Mac OS X 10.7.
NSWorkspaceMBS.fullPathForApplication(appname as string) as folderitem
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 8.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
The full path for the application, or nil if the specified application was not found.
NSWorkspaceMBS.hideOtherApplications
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 8.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
The user can hide all applications except the current one by Command-Option-clicking on an application's Dock icon.
NSWorkspaceMBS.iconForContentType(contentType as string) as NSImageMBS New in 26.1
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 26.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
contentType: An object representing a uniform type of content.
Returns the icon associated with the content type.
This method returns a default icon if the operation fails.
NSWorkspaceMBS.iconForFile(file as folderitem) as NSImageMBS
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 8.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
The returned image has an initial size of 32 pixels by 32 pixels.
Returns nil on any error.
Some examples using this method:
NSWorkspaceMBS.iconForFiles(files() as folderitem) as NSImageMBS
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 11.3 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
files: An array of folderitems, each of which contains the full path to a file.
Returns 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.
NSWorkspaceMBS.iconForFileType(filetype as string) as NSImageMBS
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 8.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
filetype: The file type, which may be either a filename extension or an encoded HFS file type.
The returned image has an initial size of 32 pixels by 32 pixels.
Returns nil on any error.
Running this in a thread can lead to crashes.
Some examples using this method:
NSWorkspaceMBS.isFilePackageAtPath(item as folderitem) as boolean
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 11.3 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Returns true if the path identifies a file package; otherwise, false if the path does not exist, is not a directory, or is not a file package.
NSWorkspaceMBS.launchApplication(appname as string) as boolean
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 8.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Returns true if the application was successfully launched or was already running; otherwise, false.
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".
See also:
NSWorkspaceMBS.launchApplication(appname as string, showicon as boolean, autolaunch as boolean) as boolean
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 8.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
appName: The name of the application to open.
showIcon: If false, the application's icon is not placed on the screen. (The icon still exists, though.)
autolaunch: If true, the autolaunch default is set as though the specified application were autolaunched at startup.
This method is provided to enable daemon-like applications that lack a normal user interface. Its use is not generally encouraged.
Returns true if the application is successfully launched or already running, and false if it can't be launched.
See also:
NSWorkspaceMBS.launchApplicationAtFile(file as folderitem, options as UInt32 = 0, configuration as dictionary = nil) as NSRunningApplicationMBS
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 11.3 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
file: The application folderitem.
options: Options to use when launching the application. see NSWorkspaceLaunch* constants.
configuration: A dictionary containing the configuration options. Possible key-value pairs are described NSWorkspaceLaunchConfiguration* functions.
error: The error is returned here.
Returns reference to newly started application.
Available in Mac OS X v10.6 and later.
See also:
NSWorkspaceMBS.launchApplicationAtFile(file as folderitem, options as UInt32, configuration as dictionary, byref error as NSErrorMBS) as NSRunningApplicationMBS
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 11.3 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
file: The application folderitem.
options: Options to use when launching the application. see NSWorkspaceLaunch* constants.
configuration: A dictionary containing the configuration options. Possible key-value pairs are described NSWorkspaceLaunchConfiguration* functions.
error: The error is returned here.
Returns reference to newly started application.
Available in Mac OS X v10.6 and later.
See also:
NSWorkspaceMBS.launchApplicationAtURL(URL as string, options as UInt32 = 0, configuration as dictionary = nil) as NSRunningApplicationMBS
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 11.3 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
url: The application URL.
options: Options to use when launching the application. see NSWorkspaceLaunch* constants.
configuration: A dictionary containing the configuration options. Possible key-value pairs are described NSWorkspaceLaunchConfiguration* functions.
error: The error is returned here.
Returns reference to newly started application.
Available in Mac OS X v10.6 and later.
See also:
NSWorkspaceMBS.launchApplicationAtURL(URL as string, options as UInt32, configuration as dictionary, byref error as NSErrorMBS) as NSRunningApplicationMBS
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 11.3 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
url: The application URL.
options: Options to use when launching the application. see NSWorkspaceLaunch* constants.
configuration: A dictionary containing the configuration options. Possible key-value pairs are described NSWorkspaceLaunchConfiguration* functions.
error: The error is returned here.
Returns reference to newly started application.
Available in Mac OS X v10.6 and later.
See also:
NSWorkspaceMBS.launchAppWithBundleIdentifier(bundleIdentifier as string, options as Integer = &h00030000, AppleEventDescriptor as Variant = nil) as Boolean
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 12.5 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
bundleIdentifier: 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: Options to use when launching the application. Values for this parameter are described in constants.
descriptor: 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.
Returns true if the application was found and launched; otherwise, false.
NSWorkspaceMBS.localizedDescriptionForType(typeName as string) as string
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
The localized description is suitable for displaying to the user.
Available in Mac OS X v10.5 and later.
NSWorkspaceMBS.menuBarOwningApplication as NSRunningApplicationMBS
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 11.3 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Requires Mac OS X 10.7.
NSWorkspaceMBS.mountedLocalVolumePaths as string()
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 11.3 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Returns an array of strings, each of which contains the full pathname of the mount point for any local volumes.
NSWorkspaceMBS.mountedRemovableMedia as string()
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 11.3 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Returns an array of strings, 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.
The items on this page are in the following plugins: MBS MacCocoa Plugin.