launchApplicationAtURL:options:configuration:error:
指定したオプションでアプリケーションを起動します
- (NSRunningApplication *)launchApplicationAtURL:(NSURL *)url options:(NSWorkspaceLaunchOptions)options configuration:(NSDictionary *)configuration error:(NSError **)error
func launchApplicationAtURL(_ url: NSURL, options options: NSWorkspaceLaunchOptions, configuration configuration: [NSObject : AnyObject], error error: NSErrorPointer) -> NSRunningApplication?
解説
指定したオプションでアプリケーションを起動します
例えば、32ビットモードで起動・64ビットモードで起動などが出来ます。
OS X 10.10の64ビットマシンで32ビットモードで起動しようとすると下記のようなメッセージが出て起動できません。
現在はX86_64で落ち着いているのであまり必要とされませんが、またプロセッサのアーキテクチャが変更されるときには使うことがあるかもしれません。
返り値
(NSRunningApplication *)NSRunningApplication?
引数
(NSURL *)url_ url: NSURL
(NSWorkspaceLaunchOptions)optionsoptions: NSWorkspaceLaunchOptions
Objective-C
NSString * const NSWorkspaceLaunchConfigurationAppleEvent;
NSString * const NSWorkspaceLaunchConfigurationArguments;
NSString * const NSWorkspaceLaunchConfigurationEnvironment;
NSString * const NSWorkspaceLaunchConfigurationArchitecture;(NSDictionary *)configurationSwift
let NSWorkspaceLaunchConfigurationAppleEvent: NSString!
let NSWorkspaceLaunchConfigurationArguments: NSString!
let NSWorkspaceLaunchConfigurationEnvironment: NSString!
let NSWorkspaceLaunchConfigurationArchitecture: NSString!configuration: [NSObject : AnyObject]
(NSError **)errorerror: NSErrorPointer
フレームワーク
ApplicationKit
クラス
NSWorkspace
使用可能
10.6-
更新時のバージョン
OS X 10.10.3
Swift1.2
関連記事(外部サイト)
例文
//NSWorkspace launchApplicationAtURL:options:configuration:error: @IBAction func function009(sender: AnyObject) { let theWorkspace : NSWorkspace = NSWorkspace.sharedWorkspace() var anError: NSError? let andPrint = NSWorkspaceLaunchOptions.AndPrint.rawValue let mask = Int( andPrint ) // cast from UInt let theURL : NSURL = NSURL(fileURLWithPath: "/Applications/iTunes.app")! let theOption : NSNumber = NSNumber(integer: 0) //32ビットモードで起動 let theArc : NSNumber = NSNumber(integer: NSBundleExecutableArchitectureI386) //64ビットモードで起動 //let theArc : NSNumber = NSNumber(integer: NSBundleExecutableArchitectureX86_64) let theConfig : [NSObject : AnyObject] = [NSWorkspaceLaunchConfigurationArchitecture : theArc] if (theWorkspace.launchApplicationAtURL(theURL, options: NSWorkspaceLaunchOptions.Async, configuration: theConfig, error: &anError) != nil){ NSLog("YES") }else{ NSLog("NO") } }