Date
1 - 3 of 3
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 ? Gerriet. P.S. NSResponder has class func allowedClasses(forRestorableStateKeyPath keyPath: String) -> [AnyClass] But UIResponder has nothing. |
|
On 16 Mar 2022, at 11:54 pm, Gerriet M. Denkmann <gerriet@...> wrote:Have you tried using secure [de]coding? https://developer.apple.com/documentation/foundation/nssecurecoding https://developer.apple.com/documentation/foundation/nscoder/2292944-decodeobject# -ben |
|
Gerriet M. Denkmann
On 18 Mar 2022, at 07:23, Ben Kennedy <ben-groups@...> wrote:replacing in:On 16 Mar 2022, at 11:54 pm, Gerriet M. Denkmann <gerriet@...> wrote:Have you tried using secure [de]coding? override func decodeRestorableState(with coder: NSCoder) all: languageFilter = coder.decodeObject(forKey: "languageFilter”) with: languageFilter = coder.decodeObject(of: [NSString.self], forKey: "languageFilter”) solved the problem. Thanks for your help! Gerriet |
|