开发者

Xcode Launch application and brint to front NSWorkspace

开发者 https://www.devze.com 2023-03-09 06:03 出处:网络
I have the following code to la开发者_如何学编程unch Address Book, now that works well, but is there a way I could launch this infront of the running application?

I have the following code to la开发者_如何学编程unch Address Book, now that works well, but is there a way I could launch this infront of the running application?

[[NSWorkspace sharedWorkspace] openFile:@"/Applications/Address Book.app" withApplication:nil];


Try the NSWorkspace method:

- (NSRunningApplication *)launchApplicationAtURL:(NSURL *)url options:(NSWorkspaceLaunchOptions)options configuration:(NSDictionary *)configuration error:(NSError **)error

Also note you should use URLForApplicationWithBundleIdentifier: rather than a fixed path. This will work even if Address Book.app is moved in a future version of OS X, or the user moves it to a different folder.


You could even use [[NSWorkspace sharedWorkspace] launchApplication: @"Address Book"].

0

精彩评论

暂无评论...
验证码 换一张
取 消