iOS 15 警告 : NSKeyedUnarchiver _warnAboutPlistType:missingInAllowedClasses:

标签 ios swift xcode cloudkit foundation

Xcode 13 和 iOS 15 在使用自定义 DataTransformer 时开始警告有关 missingAllowedClasses。关于自定义 DataTransformers 的文档很少,所以我想我会在这里发布一个问题并回答它。

[general] *** -[NSKeyedUnarchiver _warnAboutPlistType:missingInAllowedClasses:] allowed unarchiving safe plist type ''NSString' (0x1dc9a7660) [/System/Library/Frameworks/Foundation.framework]', even though it was not explicitly included in the client allowed classes set: '{(
    "'NSArray' (0x1dc99c838) [/System/Library/Frameworks/CoreFoundation.framework]"
)}'. This will be disallowed in the future.
请注意,在警告消息中,它指定了“NSArray”和缺少的类型“NSString”。

最佳答案

我遇到了这个问题 userDefaults在保存自定义模型的同时,我通过传递 [NSArray.self, NSString.self,NSNumber.self,CustomModel.self] 的类来修复它使这个警告静音。
注:在 iOS 15 之前,我刚刚通过了 NSArray类,但现在我必须通过其他类,如 NSStringNSNumber因为我的自定义模型有字符串、数字和数组。

{
  decodeData = try NSKeyedUnarchiver.unarchivedObject(
    ofClasses: [NSArray.self, NSString.self, NSNumber.self, CustomModel.self], from: customModel
  ) as? [CustomModel]
}

关于iOS 15 警告 : NSKeyedUnarchiver _warnAboutPlistType:missingInAllowedClasses:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68156835/

相关文章:

ios - 高度错误的模态 UINavigationController 栏

arrays - 在 Swift 中将字典类型 append 到数组

python - kivy xcode 7 问题 - 构建和存档有效,但验证失败

ios - AirWatch身份验证失败

ios - TestFlight ItunesConnect 导出合规性信息在按下“开始内部测试”按钮时弹出不隐藏

ios - 更改谷歌登录 ios 上的 View

ios - 字体不会加载到 iOS 应用程序中(在 Xcode 中看不到)

ios - 快速解析JSON数组

c - 从 Xcode 在 OS X 本地安装编译代码

ios - Xcode 无法打开文件