概要
TableViewを用いた時にハマったエラー
エラー
"attempt to insert row 0 into section 0, but there are only 0 rows in section 0 after the update"
ビルドするとこのエラーが出て落ちる
→ TableViewに行を作ろうとしたがセクションに行がなくてクラッシュしたのが原因
解決法
TableViewを構築する時の
numberOfRowsInSection
がnumberOfSections
になっていた
override func numberOfSections(in tableView: UITableView) -> Int {
//code
}
↓
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
//code
}
書き直して解決