Addi.Star Addi.Star - 2 months ago 10x
iOS Question

Compare NSURL String and simple Swift String

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 ")

if (webView.request?.URL == "Optional(")


// 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 == ""){