Check whether cell at indexPath is visible on screen UICollectionView
<p>I have a <code>CollectionView</code> which displays images to the user. I download these in the background, and when the download is complete I call the following func to update the <code>collectionViewCell</code> and display the image. </p>

<pre><code>func handlePhotoDownloadCompletion(notification : NSNotification) {
    let userInfo:Dictionary&lt;String,String!&gt; = notification.userInfo as! Dictionary&lt;String,String!&gt;
    let id = userInfo["id"]
    let index = users_cities.indexOf({$0.id == id})
    if index != nil {
        let indexPath = NSIndexPath(forRow: index!, inSection: 0)
        let cell = followedCollectionView.cellForItemAtIndexPath(indexPath) as! FeaturedCitiesCollectionViewCell
        if (users_cities[index!].image != nil) {
            cell.backgroundImageView.image = users_cities[index!].image!
        }
    }
}
</code></pre>

<p>This works great if the cell is currently visible on screen, however if it is not I get a 
<code>fatal error: unexpectedly found nil while unwrapping an Optional value</code> error on the following line : </p>

<pre><code> let cell = followedCollectionView.cellForItemAtIndexPath(indexPath) as! FeaturedCitiesCollectionViewCell
</code></pre>

<p>Now this function does not even need to be called if the collectionViewCell is not yet visible, because in this case the image will be set in the <code>cellForItemAtIndexPath</code> method anyway.</p>

<p>Hence my question, how can I alter this function to check whether the cell we are dealing with is currently visible or not. I know of the <code>collectionView.visibleCells()</code> however, I am not sure how to apply it here. </p>