In meiner benutzerdefinierten Kollektion Zelle Swift Abwickeln habe ichUILabel gesetzt Text unerwartet null gefunden, während ein optionaler Wert 3
@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)
}
}
und ich bin Daten boardInfoDic von collectionView
cellForItemAt indexPath:
als
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)
sendet, aber ich bekomme ich fatal error: unexpectedly found nil while unwrapping an Optional value
, wurde ich auf verschiedene Arten versucht, aber keine Verwendung. Wie kann ich dieses Problem beheben?
Outlet Verbindung mit UICollectionViewCell
ändern Zeile in 'wenn lassen string = boardInfoDic? [ "Beschreibung"] wie? String' und dann boardNameLabel.text = string. –
@NiravD Ich habe den gleichen Fehler nach dem Ändern des Codes auch – SriKanth
@NiravD aktualisiert die Frage mit Bezug auf Steckdose, ich bin verrückt von gestern Abend, um das Problem zu beheben. – SriKanth