NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
[prefs setObject:self.webView forKey:@\"webView\"];
The code above is made to save
As @fonix mentioned, you can only store a select few data types in NSUserDefault.
If you just wanted the url, it would be pretty easy to convert that to a string and save it to NSUserDefaults.
However, the crux of the question is how to "restore the WKWebview with its history intact."
Since, to 'save' the web view, you want not only the current URL being shown, but also the history, you need access the backForwardList on WKWebview.
NSMutableArray *history = [NSMutableArray array];
for(WKBackForwardListItem *item in webview.backForwardList.backList){
// use -absoluteString to convert NSURL to NSString
[history addObject:[item.url absoluteString]];
}
[[NSUserDefaults standardUserDefaults] addObject:history forKey:@"webviewHistory"];
[[NSUserDefaults standardUserDefaults] synchronize];
Saving those URLS into an NSArray, will allow you to save them to NSUserDefaults.
Then when you want to 'recreate' the webview, iterate through this array and request each url to simulate the history.
Hope this helps!