Xcode 7 beta 5 Swift 2冗余符合协议错误 [英] Xcode 7 beta 5 Swift 2 redundant conformance to protocol error

查看:239
本文介绍了Xcode 7 beta 5 Swift 2冗余符合协议错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近下载了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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆