Xcode 7 beta 5 Swift 2冗余符合协议错误 [英] Xcode 7 beta 5 Swift 2 redundant conformance to protocol error
问题描述
我最近下载了Swift 2附带的Xcode 7.下面是我尝试将我的类符合 UITableViewDataSource
和 UITableViewDelegate时出现的错误
在Xcode 6.2中运行良好但在Xcode 7 beta 5中抛出错误
I recently download Xcode 7 which comes with Swift 2. Below is the error I get when I try to conform my class to UITableViewDataSource
and UITableViewDelegate
which works perfectly well in Xcode 6.2 but throws an error in Xcode 7 beta 5
class TableViewController: UITableViewController, UITableViewDataSource, UITableViewDelegate {
}
//错误:'TableViewcontroller'与协议'UITableViewDataSource'的冗余一致性
//error: Redundant conformance of 'TableViewcontroller' to protocol 'UITableViewDataSource'
我搜索了谷歌的答案,但我无法修复它。
I have searched google for answers but I couldn't get a fix for it.
推荐答案
没有必要表明你 TableViewController
符合因为 UITableViewController
已经完成了两个协议。因此,由于继承,你的班级也将如此。
There is no need to indicate that you TableViewController
conforms to the two protocols because the UITableViewController
already does. So your class will as well due to the inheritance.
所有你需要的是:
class TableViewController: UITableViewController {
}
似乎Swift2更严格关于这个比Swift更好。
It seems Swift2 is more strict about this than Swift is.
这篇关于Xcode 7 beta 5 Swift 2冗余符合协议错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!