2017-07-06 15 views
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) { 

    } 
} 
+2

クラス名と拡張子名のタイプミスミスもあり –

+0

突然拡張機能を拡張機能として使うのではなく、プロトコルに準拠させるのが正しい方法です。読みやすさのために// MARK:ステートメントはどうなりましたか? – MacUserT

+0

@MacUserT、私は迅速な開発のためのガイドライン[リンクを参照]を読んでいましたが、実際にはこれらのガイドラインに従っている情報源はほとんど見つかりませんでした。したがって、それは常に伝統に従うために使用されます。 – Hemang

答えて

6

CHANGE:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell 
+2

基本的には、 'UITableViewDataSource'の中で' UITableViewCell'を返すプロトコルを確認しています。メソッドが変更されたことを変更します。したがって、実際の方法は決して確認されません。 –

関連する問題