Addi.Star Addi.Star - 1 year ago 113
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...

Answer Source

just compare string

if (webView.request?.url?.absoluteString == ""){
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download