nsapplication-delegate

How to send and receive NSAppleEventDescriptor when using NSWorkspace to open URLs between apps?

放肆的年华 提交于 2019-12-24 07:29:14
问题 NSWorkspace has the method open(_:withAppBundleIdentifier: [...] ) : Opens one or more files from an array of URLs. func open(_ urls: [URL], withAppBundleIdentifier bundleIdentifier: String?, options: NSWorkspace.LaunchOptions = [], additionalEventParamDescriptor descriptor: NSAppleEventDescriptor?, launchIdentifiers identifiers:) -> Bool The NSApplicationDelegate of the app you want to open has corresponding methods that are called to open the URL(s) you provide: func application(_ sender:

How to send and receive NSAppleEventDescriptor when using NSWorkspace to open URLs between apps?

倾然丶 夕夏残阳落幕 提交于 2019-12-24 07:29:12
问题 NSWorkspace has the method open(_:withAppBundleIdentifier: [...] ) : Opens one or more files from an array of URLs. func open(_ urls: [URL], withAppBundleIdentifier bundleIdentifier: String?, options: NSWorkspace.LaunchOptions = [], additionalEventParamDescriptor descriptor: NSAppleEventDescriptor?, launchIdentifiers identifiers:) -> Bool The NSApplicationDelegate of the app you want to open has corresponding methods that are called to open the URL(s) you provide: func application(_ sender:

Why isn't application:openFile: called when the application is already running?

时光总嘲笑我的痴心妄想 提交于 2019-12-11 02:59:43
问题 I would like to handle open events when a user double-clicks on a file that was created by my application, or drags such a file onto the dock icon. I've therefore implemented NSApplicationDelegate 's application:openFile: and application:openFiles: methods, which work as expected when the application is not running. However, if the application is already running when the open event occurs, the application becomes focused, but the above methods are never called (breakpoints inside them are not

macOS: Is there any way to know when the user has tried to quit an application via its Dock icon?

人盡茶涼 提交于 2019-12-07 03:13:04
问题 Is there any way for a Cocoa application to detect when the user has tried to quit it via its Dock menu, and not by some other method? Normally it's possible to catch and respond to quit events using the application delegate's applicationShouldTerminate: method. However, this method doesn't seem to distinguish between the request to quit coming from the application's main menu, from its Dock icon, from an Apple event, or any other conventional method of quitting the application. I'm curious

Why not enforce strict singleton application delegate object to use in NIBs?

北战南征 提交于 2019-11-29 15:42:40
I just ran myself round in circles, all coming down to having instantiated an app delegate object in a secondary NIB that wasn't the NSMainNibFile . Amazing how having two app delegates kicking around means you have separate managedObjectContexts . Here's a thought-- could I make my application delegate class a singleton? And safely instantiate it in more XIBs? What would that break? Also, there are some mentions on stackoverflow that [[UIApplication sharedApplication] delegate] is a "singleton" but it doesn't appear that UIApplicationDelegate protocol guarantees that, nor is the superclass

Why not enforce strict singleton application delegate object to use in NIBs?

旧街凉风 提交于 2019-11-28 09:55:12
问题 I just ran myself round in circles, all coming down to having instantiated an app delegate object in a secondary NIB that wasn't the NSMainNibFile . Amazing how having two app delegates kicking around means you have separate managedObjectContexts . Here's a thought-- could I make my application delegate class a singleton? And safely instantiate it in more XIBs? What would that break? Also, there are some mentions on stackoverflow that [[UIApplication sharedApplication] delegate] is a