Remember that your problem may not be just a syntax problem. If your webView is in a state where request == nil your application will crash at runtime.
I would rather write something like:
if let currentURL = webView.request?.URL.absoluteString { // do things ... // Your currentURL will be automatically bridged to Swift String type } else { // Just in case request is nil ... }
Matteo piombo
source share