3

Thanks to the bellow question's answer, I figured out how to use Cookies between multiple WKWebView by using WKProcessPool.

Cookie sharing between multiple WKWebViews

And then I'm now trying to permanently store the WKProcessPool object (of my singleton object) by using NSUserDefaults.

I've got the following error. Attempt to insert non-property list object

So I tries to fix the error by converting WKProcessPool object into NSData by NSKeyedArchiver. But It cannot be done because WKProcessPool does not implement encodeWithCoder: and init:aDecoder.

How can I solve this problem to store WKProcessPool object permanently?

Community
  • 1
  • 1
Mike
  • 131
  • 1
  • 6

1 Answers1

0

You need to implement NSCoding for your custom objects. Here is Ray Wenderlich's tutorial


Edit:

I really didn't have idea that WKProcessPool is in built class, since apple doesn't implemented the NSCoding in it and I can't even see the public properties of this class, so even if you subclass it, you don't have any idea which properties to encode/decode.

You need to find out other solution instead of archiving/archiving the objects. Even if you achieve something using category I'm afraid that you will get the expected result.

Community
  • 1
  • 1
Inder Kumar Rathore
  • 39,458
  • 17
  • 135
  • 184
  • You mean that I should make a subclass of WKProcessPool object and implement NSCoding? If so, I tried before but I can't figure out how to do that. If possible, show me the overview of your implementation. – Mike Oct 11 '15 at 09:00
  • ``extension WKProcessPool { convenience init(coder aDecoder: NSCoder) { aDecoder.decodeObject() self.init() } func encodeWithCoder(aCoder: NSCoder) { aCoder.encodeObject(self) } } `` I tried to implement NSCoding methods through ``extension``. But this will recreate new object each time even if it uses ``initWithCoder:`` initializer. How can I implement correctly? – Mike Oct 11 '15 at 09:39