なぜ、tableView.dequeueReusableCell(withIdentifier:for:)と表記するのでしょう?
dequeueReusableCell(withIdentifier:for:)だけではダメなのでしょうか?
tableView(_:cellForRowAt:)メソッドはUITabelViewDataSourceクラスで宣言されていて、
dequeueReusableCell(withIdentifier:for:)メソッドはUITableViewクラスで宣言されているので、
ネストでもなさそうですし。
この二つのメソッドはセットで使うみたいな決まりでもあるのでしょうか?
swift5
1 2class ListViewController : UITableViewController, XMLParserDelegate { 3 4 override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 5 6 let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) 7 cell.textLabel?.text = items[indexPath.row].title 8 9 return cell 10 11 } 12} 13
あと、なぜオーバーライドが必要?
TableView -> UITableViewDataSource -> func tableView(_:cellForRowAt:)
TableView -> UITableViewController -> ListViewController
ListViewControllerが継承しているUITableViewControllerにはtableView(_:cellForRowAT:)メソッドはそもそも定義されていないはず。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/06/10 09:01