“InboxTableViewController”与协议“UITableViewDataSource”的冗余一致性

时间:2018-01-31 21:29:15

标签: ios swift4

我在iOS开发中有新功能,当我构建我的项目时,它会向我显示此错误

  

“'InboxTableViewController'与协议'UITableViewDataSource'的冗余一致性''

这是代码

class InboxTableViewController: UITableViewController,
                                UITableViewDataSource,
                                UIGestureRecognizerDelegate {
    private let CARD_CELL        = "CardCell"
    private let VIEW_CARD_SEGUE  = "ViewCardSegue"
    private let EDIT_CARD_SEGUE  = "EditCardSegue"
    private let TAG_TITLE_LABEL  = 1
    private let TAG_DETAIL_LABEL = 2
    private let TAG_CANVAS       = 3

    private let agent = RenderingAgent()
    private var listeningForChangeEvents = false

    var cards: ArrayList {
        return DataUtility.AllCards

1 个答案:

答案 0 :(得分:2)

通过继承UITableViewController已经实现UITableViewDataSource,因此再次列出它会导致此错误。你只需要这个(那里没有UITableViewDataSource):

class InboxTableViewController: UITableViewController, UIGestureRecognizerDelegate

您可以在UITableViewController部分的Conforms To official docs中看到它已符合UITableViewDataSource。只需为您要实现的UITableViewDataSource方法添加覆盖,例如:

class InboxTableViewController: UITableViewController,
                                UIGestureRecognizerDelegate {
    private let CARD_CELL        = "CardCell"
    private let VIEW_CARD_SEGUE  = "ViewCardSegue"
    private let EDIT_CARD_SEGUE  = "EditCardSegue"
    private let TAG_TITLE_LABEL  = 1
    private let TAG_DETAIL_LABEL = 2
    private let TAG_CANVAS       = 3

    private let agent = RenderingAgent()
    private var listeningForChangeEvents = false

    var cards: ArrayList {
        return DataUtility.AllCards
    }

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        // implement
    }