NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
[prefs setObject:self.webView forKey:@"webView"];
The code above is made to save a WKWebView object but I'm getting a compiler error:
2014-11-08 14:58:52.561 Restoration[2431:482391] Property list invalid for format: 200 (property lists cannot contain objects of type 'CFType') 2014-11-08 14:58:52.564 Restoration[2431:482391] Attempt to set a non-property-list object > as an NSUserDefaults/CFPreferences value for key webView 2014-11-08 14:58:52.566 Restoration[2431:482391] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Attempt to insert non-property list object > for key webView' * First throw call stack: (0x2c491c1f 0x39c78c8b 0x2c491b65 0x2c4cbe51 0x2c436599 0x2c4358d7 0x2c4cc0d1 0x2c4cb769 0x2c4ce95b 0x2c4ce875 0x2d0eab69 0x66bdf 0x2f981c2b 0x2f981bd1 0x2f96c863 0x2f98163d 0x2f981317 0x2f97abe1 0x2f9513dd 0x2fbc4c29 0x2f94fe39 0x2c458377 0x2c457787 0x2c455ded 0x2c3a4211 0x2c3a4023 0x3379d0a9 0x2f9b01d1 0x66ead 0x3a1f8aaf) libc++abi.dylib: terminating with uncaught exception of type NSException
How can I save the WKWebView and restore it with its history intact?
EDIT:
8 months have passed and there's no solution to this problem...
EDIT 2:
I'm making a web browser and it is crucial when the user restarts the app the web views (tabs) to restore so he can press the back button and go back.
If I save the previous URLs in a simple list I can't put them back into the web view when the app restarts. I can only load the first page. So, the user can't press back because there is no page to back. If it was as simple as saving a list of URLs I wouldn't start a bounty. Since, a web browser is a very complex app I've been very close to the fundamentals of the webViews and I have even submitted 3 bugs from which only 2 have been resolved. Including the infamous screenshot bug.
The standardUserDefaults method does work with UIWebView but Apple states that all developers should use the WKWebView following the release of iOS 7. I'm expecting UIWebView to be deprecated in the near future.