I'm trying to check if my url is nil or not since I have a background thread that is getting the url from my database.
I tried doing this travelURL.absoluteString == ""
and travelURL != nil
but the problem still persists.
I declared my variable as var travelURL: URL!
You can use if let
syntax:
if let url = travelURL {
// Here you can use url, it is not nil
} else {
// Here url is nil
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.