类型'ProfilesTableViewController'不符合Xcode 6 GM种子中的协议'UITableViewDataSource'

Hri*_*sov 3 uitableview ios swift xcode6

今天我迁移到Xcode 6 GM种子,现在我收到以下错误:

类型'ProfilesTableViewController'不符合协议'UITableViewDataSource'.

我已经压倒了numberOfRowsInSection,cellForRowAtIndexPath而且numberOfSectionsInTableView.
事实上,直到今天一切正常.我注意到,当我删除UITableViewDataSource一切工作正常,没有错误发生.所以..是否有必要再使用' UITableViewDataSource',或者只是覆盖它的功能?

ser*_*gio 5

这段代码很好编译:

class ProfileTableViewController: UITableViewController, UITableViewDelegate, UITableViewDataSource {


override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 1
}

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

    let cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier("foo", forIndexPath: indexPath) as UITableViewCell

    return cell
}
}
Run Code Online (Sandbox Code Playgroud)

因此,您绝对可以子类化UITableViewController并定义其UITableViewDataSource协议实现.

请注意我正在使用override关键字,并且我没有使用自动解包的参数 - 即,不是这样的:

override func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
Run Code Online (Sandbox Code Playgroud)

这在之前的Xcode 6测试版中是正确的.