Check if url image exist <p>I'm trying to check if a url image exist using a if statement. However when trying to test it by wrong image url it keep returning:</p> <blockquote> <p>fatal error: unexpectedly found nil while unwrapping an Optional value.</p> </blockquote> <p>code:</p> <pre><code>var httpUrl = subJson["image_url"].stringValue let url = NSURL(string: httpUrl) let data = NSData(contentsOfURL: url!) if UIImage(data: data!) != nil { } </code></pre>