ios - WKProcessPool 可以使用 NSUserDefaults 或其他东西永久存储吗?

标签 ios xcode swift cookies wkwebview

感谢下面问题的回答,我想出了如何通过使用 WKProcessPool 在多个 WKWebView 之间使用 Cookie。

Cookie sharing between multiple WKWebViews

然后我现在尝试使用 NSUserDefaults 永久存储 WKProcessPool 对象(我的单例对象)。

我遇到了以下错误。 尝试插入非属性列表对象

所以我尝试通过 NSKeyedArchiver 将 WKProcessPool 对象转换为 NSData 来修复错误。 但它无法完成,因为 WKProcessPool 没有实现 encodeWithCoder:init:aDecoder

如何解决这个问题以永久存储 WKProcessPool 对象?

最佳答案

您需要实现 NSCoding为您的自定义对象。这是 Ray Wenderlich's tutorial


编辑:

我真的不知道WKProcessPool在内置类中,因为苹果没有在其中实现 NSCoding 而且我什至看不到这个类的公共(public)属性,所以即使你继承它,你也不知道编码/解码哪些属性。

您需要找出其他解决方案,而不是归档/归档对象。即使你使用 category 取得了一些成就,恐怕你也会得到预期的结果。

关于ios - WKProcessPool 可以使用 NSUserDefaults 或其他东西永久存储吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33063194/

相关文章:

iOS 创建 Siri 图标和动画

ios - 没有为 rootViewController 调用 viewDidLoad

iPhone : Leave API changing pages

swift - Eureka - 自定义内联行

iOS模拟器声音

ios - 从 Apple Watch 扬声器播放声音

ios - 如何在 iOS 7 中创建上下箭头

ios - 无法使用 SWIFT 2 从附件标签 rss xml 中提取 url 值

swift - 将 searchBar 添加到 tableHeaderView 添加底部空白空间

ios - XCode 9 停止调试和运行应用程序并给出错误 "The LLDB RPC server has crashed."