2016-07-01 6 views
0

Xcode 8ベータ版でtableViewのコードを書いてから、実際のXcode 7でそれをやろうとしました。以下のコードは、UITableViewDataSourceの問題を除いて正しいようです。コンパイラは言う:UITableViewDataSourceがsmthを要求しました

タイプ「SettingsVCは」プロトコルに準拠していない「UITableViewDataSource」

私は必要なすべてのメソッドを実装していると思うのCoSそれは、奇妙です。

class SettingsVC: UIViewController, UITableViewDelegate, UITableViewDataSource { 

    @IBOutlet weak var chooseTable: UITableView! 

    var tableArray = [String]() 

    override func viewDidLoad() { 
     tableArray = ["1", "2", "3", "4", "5"] 
    } 

    override func viewDidAppear(animated: Bool) { 
     chooseTable.reloadData() 
    } 

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 
     return tableArray.count 
    } 

    func tableView(tableView: UITableView, cellForRowAt indexPath: NSIndexPath) -> UITableViewCell { 
     let cell = tableView.dequeueReusableCellWithIdentifier(tableArray[indexPath.item], forIndexPath: indexPath) 
     cell.textLabel?.text = tableArray[indexPath.row] 
     return cell 
    } 
} 

P.S. Xcode 8ではすべてがうまく動作します。私がテーブルを使用する4つのViewControllerで見られる同じ問題。

func tableView(tableView: UITableView, cellForRowAt indexPath: NSIndexPath) -> UITableViewCell { 

で:置き換え

+0

ました使用しようとしている機能の署名をチェックしますか? – Wain

答えて

2

のXcode 7は、SWIFT 3.0をサポートしていません、あなたはUITableViewDataSource

ためスウィフト3.0メソッドを使用している

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 

乾杯

関連する問題