在我的自定义 collectionview 单元格中,我有
@IBOutlet weak var boardNameLabel: UILabel!
var boardInfoDic: Dictionary? = [String : AnyObject]()
func updateItemAtIndexPath(_ indexPath: NSIndexPath) {
if let string = boardInfoDic?["description"]
{
boardNameLabel.text = String(format: "%@", string as! String)
}
}
我从collectionView
cellForItemAt indexPath:
as向 boardInfoDic 发送数据
let boardsCollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: KBoardsCollectionViewCellIdentifier, for: indexPath) as! BoardsCollectionViewCell
boardsCollectionViewCell.boardInfoDic = self.boardsDataArray?[indexPath.item] as Dictionary<String, AnyObject>?
boardsCollectionViewCell.updateItemAtIndexPath(indexPath as NSIndexPath)
但我得到了fatal error: unexpectedly found nil while unwrapping an Optional value
,我尝试了多种方式但没有用。我该如何解决这个问题?