I am trying to open a website in my app, but for some reason one line keeps returning nil, heres my code:
let url = URL(string: "http://en.wikipedia.org/wiki/\(element.Name)")!
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
}
It's the first line (let url = URL...
) that keeps on returning this error:
fatal error: unexpectedly found nil while unwrapping an Optional value.
What should I do to fix this?