I found this SO that gives an explanation of how to set local storage using javascript.
I'm trying to translate it from Swift to Objective-C. For some reason it's throwing a fit at me like I'm missing a bracket but I can't seem to figure it out. Any ideas how to correctly translate that Swift to iOS?
Here's what I have so far:
- (void)webView:(WKWebView *)webView
didFinishNavigation:(WKNavigation *)navigation {
[webView evaluateJavaScript:@"localStorage.getItem(\"key\")" completionHandler:^(id result, NSError *error) {
if (error == nil) {
[webView evaluateJavaScript:@"localStorage.setItem(\"key\", \"value\")" completionHandler:^(id result, NSError *error) {
if (error == nil) {
webView.reload();
}
}
}];
}
}];
}
Indeed, you have an extra bracket in your code.