简体   繁体   English

Xcode 7 beta 5 Swift 2冗余符合协议错误

[英]Xcode 7 beta 5 Swift 2 redundant conformance to protocol error

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 我最近下载了Swift 2随附的Xcode7。以下是我尝试使我的类与UITableViewDataSourceUITableViewDelegate兼容的错误,它们在Xcode 6.2中运行良好,但在Xcode 7 beta 5中引发错误

class TableViewController: UITableViewController, UITableViewDataSource, UITableViewDelegate {
}

//error: Redundant conformance of 'TableViewcontroller' to protocol 'UITableViewDataSource' //错误:“ TableViewcontroller”与协议“ UITableViewDataSource”的冗余一致性

I have searched google for answers but I couldn't get a fix for it. 我已经在google上搜索了答案,但无法解决。

There is no need to indicate that you TableViewController conforms to the two protocols because the UITableViewController already does. 因为UITableViewController已经符合,所以不需要指出您的TableViewController符合这两个协议。 So your class will as well due to the inheritance. 因此,由于继承,您的课程也将如此。

All you need is: 所有你需要的是:

class TableViewController: UITableViewController {
}

It seems Swift2 is more strict about this than Swift is. 似乎Swift2比Swift更严格。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM