Skip to content

Instantly share code, notes, and snippets.

@Bahallack
Created June 19, 2023 15:45
Show Gist options
  • Select an option

  • Save Bahallack/1ccb92d4a5efe1241f8edc0ee73dfab4 to your computer and use it in GitHub Desktop.

Select an option

Save Bahallack/1ccb92d4a5efe1241f8edc0ee73dfab4 to your computer and use it in GitHub Desktop.

Revisions

  1. Bahallack created this gist Jun 19, 2023.
    11 changes: 11 additions & 0 deletions WebArchiveDataManager.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    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)")
    }
    }