How to catch null pointer exception in Swift?
<p>I have got this piece of code :     </p>

<pre><code>var graphPoints:[Int] = DBController().dosmth()
</code></pre>

<p>And this calls a method which is supposed to return an array of <code>Int</code>. But how can I handle the situation when the values passed are not <code>Int</code>? At the moment it just throws this </p>

<p><code>fatal error: unexpectedly found nil while unwrapping an Optional value</code> </p>

<p>and I want to catch like so :</p>

<pre><code>do{
    var graphPoints:[Int] = DBController().dosmth()
}
catch{ }
</code></pre>

<p>But this throws errors. Would be grateful if someone could point out what i am doing wrong.</p>