I am using this code to unarchive an array of a custom object from UserDefaults:
guard let data = UserDefaults.standard.data(forKey: "key") else {
return
}
let customClassArray = try NSKeyedUnarchiver.unarchivedObject(ofClasses:
[NSMutableArray.self,
NSNull.self,
NSMutableDictionary.self,
NSNumber.self,
NSString.self,
NSArray.self,
CustomClass.self], from: data) as? [CustomClass]
But I get this error spammed several times:
[NSKeyedUnarchiver validateAllowedClass:forKey:] allowed unarchiving safe plist type ''NSString' (0x1e5fae918) [/System/Library/Frameworks/Foundation.framework]' for key 'NS.keys', even though it was not explicitly included in the client allowed classes set: '{(
"'NSMutableArray' (0x1e5fa7050) [/System/Library/Frameworks/CoreFoundation.framework]",
"'NSNull' (0x1e5fa68a8) [/System/Library/Frameworks/CoreFoundation.framework]",
"'NSMutableDictionary' (0x1e5fa6fb0) [/System/Library/Frameworks/CoreFoundation.framework]"
)}'. This will be disallowed in the future.
along with this error:
[NSKeyedUnarchiver validateAllowedClass:forKey:] allowed unarchiving safe plist type ''NSNumber' (0x1e5fae8c8) [/System/Library/Frameworks/Foundation.framework]' for key 'NS.objects', even though it was not explicitly included in the client allowed classes set: '{(
"'NSMutableArray' (0x1e5fa7050) [/System/Library/Frameworks/CoreFoundation.framework]",
"'NSNull' (0x1e5fa68a8) [/System/Library/Frameworks/CoreFoundation.framework]",
"'NSMutableDictionary' (0x1e5fa6fb0) [/System/Library/Frameworks/CoreFoundation.framework]"
As you can see in my code, I have listed out the classes such as NSMutableArray
, NSNull
, NSMutableDictionary
and NSString
. Why am I still getting this error?