I have a function in Xcode 6.2 where I want to compare a URL returned from webview and compare it with a static string. I am doing it like this:
func webViewDidFinishLoad(webView: UIWebView){
let currentURL = webView.request?.URL
print("Webview did finish load ")
println(currentURL)
if (webView.request?.URL == "Optional(http://addi.star.com/adminpanel/first.php/login)")
{
println("voilaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
// code for dissming the view
//self.dismissViewControllerAnimated(true, completion: nil)
}
}
...but it's not working. Can someone please explain how I can compare currentURL to static URL so that I can dismiss the view? I think I'm missing the types to compare it successfully, but there must be a way to do this...
just compare string
if (webView.request?.url?.absoluteString == "http://addi.star.com/adminpanel/first.php/login"){
//code
}