我有這個代碼斯威夫特將在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裏面,它重定向我的appdelegate上'reloadData文件'和 –
你需要建立一個__exception breakpoint__作爲未打印,除了那些已經在這個問題什麼我已經提到過,不僅僅是一個正常的斷點。拋出異常時異常斷點會暫停執行,並讓您調查異常的確切原因。 –