Reputation: 1105
I want to check if the video url works before embedding it into my webView. Because if the user enters a url that doesn't resolve or contain video then the webView will display a whitebox
// (if MyVariables.link is valid)
{....
let Code:NSString = "<iframe width=\(width) height=\(height) src=\(MyVariables.link) frameborder=\(frame)></iframe>";
self.wView.loadHTMLString(Code as String, baseURL: nil)
}
Upvotes: 4
Views: 2116
Reputation: 22343
Check the url by using canOpenURL
from UIApplication
if let url = NSURL(string: yourUrlString) {
var canOpen = UIApplication.sharedApplication().canOpenURL(url)
}
Upvotes: 7