Last active
May 4, 2018 02:59
-
-
Save mlcollard/86591f71024d2da9f65a to your computer and use it in GitHub Desktop.
iOS: Loading a WKWebView with a web URL
This file contains 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
/* Load given URL into web view */ | |
/* Note: For http:, need to setup App Transport Settings to allow: | |
Key: App Transport Security Settings | |
Subkey: Allow Arbitrary Loads to YES | |
Produces: | |
<key>NSAppTransportSecurity</key> | |
<dict> | |
<key>NSAllowsArbitraryLoads</key> | |
<true/> | |
</dict> | |
This allows any URL, but is NOT good practice. | |
Should only allow specific URLS (Exception Domains | |
*/ | |
guard let url = URL(string: "http://mlcollard.net/cs489iOSS18/") else { | |
print("Error: Unable to load url") | |
return | |
} | |
let requestObj = URLRequest(url: url) | |
self.classWebView?.load(requestObj) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment