Skip to content

Instantly share code, notes, and snippets.

@DimaRU
Forked from Bahallack/WebArchiveDataManager.swift
Created September 26, 2023 20:54
Show Gist options
  • Select an option

  • Save DimaRU/972e05c7015e8aee75fd15f7cb6086da to your computer and use it in GitHub Desktop.

Select an option

Save DimaRU/972e05c7015e8aee75fd15f7cb6086da to your computer and use it in GitHub Desktop.
loadWebArchive
func loadWebArchive(named name: String, into webView: WKWebView) {
let fileURL = self.webArchiveDirectoryURL.appendingPathComponent("\(name).webarchive")
do {
let archiveData = try Data(contentsOf: fileURL)
webView.load(archiveData, mimeType: "application/x-webarchive", characterEncodingName: "", baseURL: fileURL)
print("Web archive loaded from: \(fileURL.path)")
} catch {
print("Error loading web archive: \(error.localizedDescription)")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment