Created
July 22, 2020 15:26
-
-
Save vinbrule/fdce5cf7e221f34d2e400bfada502438 to your computer and use it in GitHub Desktop.
load webarchieve locally swift mac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import AppKit | |
| import PlaygroundSupport | |
| import WebKit | |
| var webView: WKWebView! | |
| webView = WKWebView(frame: CGRect(x: 0, y: 0, width: 600, height: 800.0)) | |
| var filePath = URL.init(fileURLWithPath: "/Users/van/Downloads/firefox/01-interview preparation/leetcode/facebook/Longest Substring Without Repeating Characters - LeetCode Articles.webarchive") | |
| print(filePath) | |
| let fileDirectoryURL = filePath.deletingLastPathComponent() | |
| webView.loadFileURL(filePath, allowingReadAccessTo: fileDirectoryURL) | |
| //if let url = URL(string: "https://www.apple.com") { | |
| // let request = URLRequest(url: url) | |
| // webView.load(request) | |
| //} | |
| let nibFile = NSNib.Name("MyView") | |
| var topLevelObjects : NSArray? | |
| Bundle.main.loadNibNamed(nibFile, owner:nil, topLevelObjects: &topLevelObjects) | |
| let views = (topLevelObjects as! Array<Any>).filter { $0 is NSView } | |
| // Present the view in Playground | |
| PlaygroundPage.current.liveView = webView//views[0] as! NSView |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Past it into the playground and see the results.