how to set allowedClasses for UIStateRestorationKeyedUnarchiver

Gerriet M. Denkmann

class ViewController: UIViewController
override func decodeRestorableState(with coder: NSCoder)
NSLog("\(#function) will super; coder \(coder); allowedClasses \(String(describing: coder.allowedClasses))”)
// will super; coder <UIStateRestorationKeyedUnarchiver: 0x103eb18c0>; allowedClasses nil

super.decodeRestorableState(with: coder)

if let rawMode = coder.decodeObject(forKey: "misterRaw") as? Int
// *** -[UIStateRestorationKeyedUnarchiver validateAllowedClass:forKey:] allowed unarchiving safe plist type ''NSNumber' (0x1d9f501e8) [/System/Library/Frameworks/Foundation.framework]' for key 'misterRaw', even though it was not explicitly included in the client allowed classes set: '{( )}'. This will be disallowed in the future.

localePicker.masterMode = LocalePickerComponents(rawValue: rawMode)


So: How to explicitly include NSNumber into the client allowed classes set ?


NSResponder has class func allowedClasses(forRestorableStateKeyPath keyPath: String) -> [AnyClass]
But UIResponder has nothing.

Join { to automatically receive all group messages.