# SDL: cocoa: Use \`-\[NSApplicationDelegate applicationSupportsSecureRestorableState\]\`. (3817f)

**URL:** <https://discourse.libsdl.org/t/sdl-cocoa-use-nsapplicationdelegate-applicationsupportssecurerestorablestate-3817f/47564>\
**Category:** SDL Commits\
**Created:** [November 28, 2023, 5:42pm UTC](https://discourse.libsdl.org/t/sdl-cocoa-use-nsapplicationdelegate-applicationsupportssecurerestorablestate-3817f/47564 "2023-11-28T17:42:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDLPushPostBot](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sdlpushpostbot/32/4370_2.png) [@SDLPushPostBot](https://discourse.libsdl.org/u/SDLPushPostBot)\
**Post date:** [November 28, 2023, 5:42pm UTC](https://discourse.libsdl.org/t/sdl-cocoa-use-nsapplicationdelegate-applicationsupportssecurerestorablestate-3817f/47564/1 "2023-11-28T17:42:03Z")

</div>

> <https://github.com/libsdl-org/SDL/commit/3817f5126e67e5f2f2b5c7e0196d42c27e7fdfd0>
>
> This prevents warnings at startup on macOS Sonoma (14.0).
> 
> (cherry picked from c…ommit 7d25a443c45450287e0a3ec5c1eb0e417647070e)

````diff
From 3817f5126e67e5f2f2b5c7e0196d42c27e7fdfd0 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Tue, 28 Nov 2023 12:24:33 -0500
Subject: [PATCH] cocoa: Use `-[NSApplicationDelegate
 applicationSupportsSecureRestorableState]`.

This prevents warnings at startup on macOS Sonoma (14.0).

(cherry picked from commit 7d25a443c45450287e0a3ec5c1eb0e417647070e)
---
 src/video/cocoa/SDL_cocoaevents.m | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/video/cocoa/SDL_cocoaevents.m b/src/video/cocoa/SDL_cocoaevents.m
index 3674965c8b56..7673d226d83a 100644
--- a/src/video/cocoa/SDL_cocoaevents.m
+++ b/src/video/cocoa/SDL_cocoaevents.m
@@ -133,6 +133,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath
                       ofObject:(id)object
                         change:(NSDictionary *)change
                        context:(void *)context;
+- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app;
 @end
 
 @implementation SDLAppDelegate : NSObject
@@ -319,6 +320,22 @@ - (void)handleURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEv
     SDL_SendDropComplete(NULL);
 }
 
+- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app
+{
+ // This just tells Cocoa that we didn't do any custom save state magic for the app,
+ // so the system is safe to use NSSecureCoding internally, instead of using unencrypted
+ // save states for backwards compatibility. If we don't return YES here, we'll get a
+ // warning on the console at startup:
+ //
+ // ```
+ // WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES.
+ // ```
+ //
+ // More-detailed explanation:
+ // https://stackoverflow.com/questions/77283578/sonoma-and-nsapplicationdelegate-applicationsupportssecurerestorablestate/77320845#77320845
+ return YES;
+}
+
 @end
 
 static SDLAppDelegate *appDelegate = nil;

````
