LoginSignup
0
1

More than 1 year has passed since last update.

【Swift】【UITableView】セクションに行がない??

Last updated at Posted at 2021-04-14

概要

TableViewを用いた時にハマったエラー

エラー

"attempt to insert row 0 into section 0, but there are only 0 rows in section 0 after the update"

ビルドするとこのエラーが出て落ちる

→ TableViewに行を作ろうとしたがセクションに行がなくてクラッシュしたのが原因

解決法

TableViewを構築する時の
numberOfRowsInSectionnumberOfSectionsになっていた

override func numberOfSections(in tableView: UITableView) -> Int {
     //code
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
     //code
}

書き直して解決

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1