0
UITableView
プロトコルを実装するために私はthisのガイドラインに従っています。しかし、今は、私に間違いを見せている、私が間違っていることは何ですか?UITableViewプロトコルに準拠させるには良い方法はありますか?
'RequestsViewController'がプロトコル 'UITableViewDataSource'に準拠していません。 THIS
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> RequestsTableViewCell
TO
class RequestsViewController: UIViewController {
...
...
}
extension RequestsViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return arrayRequests.count
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 100
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> RequestsTableViewCell {
let cell:RequestsTableViewCell = (tableView.dequeueReusableCell(withIdentifier: cellIdentifier) as! RequestsTableViewCell)
//Doing some assignments.
return cell
}
}
extension RequestsViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
}
}
クラス名と拡張子名のタイプミスミスもあり –
突然拡張機能を拡張機能として使うのではなく、プロトコルに準拠させるのが正しい方法です。読みやすさのために// MARK:ステートメントはどうなりましたか? – MacUserT
@MacUserT、私は迅速な開発のためのガイドライン[リンクを参照]を読んでいましたが、実際にはこれらのガイドラインに従っている情報源はほとんど見つかりませんでした。したがって、それは常に伝統に従うために使用されます。 – Hemang