简体   繁体   中英

Redundant conformance of 'InboxTableViewController' to protocol 'UITableViewDataSource'

I have new in iOS developing and when i build my project its show me this error

"Redundant conformance of 'InboxTableViewController' to protocol 'UITableViewDataSource"'

This is code

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

By subclassing UITableViewController you already implement UITableViewDataSource , therefore listing it again causes this error. You just need this (no UITableViewDataSource there):

class InboxTableViewController: UITableViewController, UIGestureRecognizerDelegate

You can see in official docs of the UITableViewController in section Conforms To that it already conforms to UITableViewDataSource . Just add override to those UITableViewDataSource methods that you want to implement, so eg:

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
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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