致命错误:在 UICollectionView 中使用 Alamofire 解包可选值 Swift 时意外发现 nil

Ash*_*ues 0 ios uicollectionview uicollectionviewcell swift swift2

我正在使用 Alamofire 从网络服务获取图像。我使用以下代码在 UICollectionView 的自定义单元格中显示这些图像

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
    let reuseIdentifier = "cell"
    // get a reference to our storyboard cell
    let cell : ImageCollectionCell = collectionView.dequeueReusableCellWithReuseIdentifier("cellCollection", forIndexPath: indexPath) as! ImageCollectionCell

    // Use the outlet in our custom class to get a reference to the UILabel in the cell
    cell.backgroundColor = UIColor.yellowColor() // make cell more visible in our example project
    let imageGalleryURLString = self.MutableArray.objectAtIndex(indexPath.row) .valueForKey("thumbnail") as! String
    let imageURL = NSURL(string:imageGalleryURLString)
    cell.imageviewCollectionCell.sd_setImageWithURL(imageURL)
    return cell
}
Run Code Online (Sandbox Code Playgroud)

但应用程序在“ cell.imageviewCollectionCell.sd_setImageWithURL(imageURL) ”处崩溃,显示“致命错误:在展开可选值时意外发现 nil

我已经浏览了所有可能的链接,但我还不满意

Ash*_*ues 5

抱歉,我已经在 viewDidLoad 方法中注册了自定义 UICollectionViewCell 使用

collectionView!.registerClass(customCell.self, forCellWithReuseIdentifier: "Cell")
Run Code Online (Sandbox Code Playgroud)

我正在使用故事板。删除此代码后一切正常。