"NSPersistentUIKeyedUnarchiver allowed unarchiving safe plist type" error during NSViewController restoration

In my macOS app I'm encoding and restoring the state of a view between app launches. It used to work fine until I updated to macOS 14 and Xcode 15. Now Xcode logs this error when calling coder.decodeObject(forKey: "string"):

*** -[NSPersistentUIKeyedUnarchiver validateAllowedClass:forKey:] allowed unarchiving safe plist type ''NSString' (0x1dfa40918) [/System/Library/Frameworks/Foundation.framework]' for key 'string', even though it was not explicitly included in the client allowed classes set: '{(
)}'. This will be disallowed in the future.

The following sample code reproduces the issue:

class ViewController: NSViewController {
    
    override func viewDidAppear() {
        invalidateRestorableState()
    }
    
    override class func allowedClasses(forRestorableStateKeyPath keyPath: String) -> [AnyClass] {
        return [NSString.self]
    }

    override func encodeRestorableState(with coder: NSCoder) {
        coder.encode("asdf", forKey: "string")
    }
    
    override func restoreState(with coder: NSCoder) {
        print(coder.decodeObject(forKey: "string") as! String)
    }

}

What am I doing wrong?

"NSPersistentUIKeyedUnarchiver allowed unarchiving safe plist type" error during NSViewController restoration
 
 
Q