NSApplicationDelegate on Mac Catalyst

I'd like to handle it so that it doesn't quit even if I press the Dock Icon's "Quit menu" on Mac Catalyst.

Please let me know how to use the delegate func below on Mac Catalyst.

func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply 

Replies

There is currently no API that would allow you to prevent app termination on Mac Catalyst.

Please consider automatically saving your app state + using state restoration like you would on iOS. The app will transition to the background state during termination (from 00:27 onward), and you can use beginBackgroundTaskWithName / endBackgroundTask for last-second cleanup tasks, if necessary.

If your use case does not lend itself to this, please use Feedback Assistant to request new API.

You can not set your own NSApplicationDelegate on Mac Catalyst, as the one provided by the OS is central to much of the Mac Catalyst functionality. Only the UIApplicationDelegate is under your control.

  • My case is not suitable for that. If users press the Dock Icon’s quit menu while the file transfer is in progress on my app, I want to notify the user of the current app status and get confirmation whether the user really wants to shut down the app or not.

    What should I do to request a new API?

  • In this case, please consider using a background NSURLSession. This will allow the upload to complete even if your app is no longer running.

Add a Comment