を与える私はこのコードスウィフトはuicollectionviewにセルを挿入するには私にエラー
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int
{
return comments.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = commentSection.dequeueReusableCell(withReuseIdentifier: cellId, for: indexPath) as! CommentCell
return cell
}
を持っていると私は、細胞
DispatchQueue.main.async{
let indexPath = IndexPath(row: self.comments.count, section: 0)
self.commentSection.insertItems(at: [indexPath])
self.commentSection.reloadData()
}
を挿入しますが、私はこのコードを実行するたびに、それはこれを印刷し、この以下の機能を持っていますエラー
libc++abi.dylib: terminating with uncaught exception of type NSException
私はAppDelegateファイルにリダイレクトされます。エラーは非常にはっきりと書き込まれていますが10問題を理解できない
は、デバッガで例外ブレークポイントを設定し、実際のエラーや、あなたの質問にそれを引き起こし行が含まれます。 –
@DávidPásztor私は 'DispatchQueue'の中の3行全てにブレークポイントを置いて、 'reloadData'のAppdelegateファイルにリダイレクトしました。質問に既にあるもの以外は何も表示しませんでした。 –
__exception breakpoint__を私はすでに、通常のブレークポイントだけでなく、言及した。例外ブレークポイントは、例外がスローされたときに実行を停止し、例外の正確な原因を調査できるようにします。 –