Posts

Post not yet marked as solved
3 Replies
696 Views
Hi,I'm trying to load a local html file where I just saved some changes to in a WKWebView. I used to do it with loadHTMLString(), but unfortunatly there seems to be no way to enable back/forward swipe gestures using loadHTMLString().Writing to the file works just fine, but I can't seem to load the edited file. I keep getting the original. Anyone know what I'm doing wrong here?let file = "localFile.html" let text = "Some changes" if let dir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first { let fileURL = dir.appendingPathComponent(file) //writing do { try text.write(to: fileURL, atomically: false, encoding: .utf8) } catch {/* error handling here */} //reading do { let loadedText = try String(contentsOf: fileURL, encoding: .utf8) print(loadedText) // checking saved text let url = URL(fileURLWithPath: Bundle.main.path(forResource: "localFile", ofType: ".html")!) let request = URLRequest(url: url) webView.load(request) } catch {/* error handling here */} }
Posted
by hilmarorg.
Last updated
.