Type 'ViewController' does not conform to protocol 'UITableViewDataSource'

后端 未结 17 2575
旧巷少年郎
旧巷少年郎 2020-11-29 03:02

Started practice swift. In singleViewController I am trying to make a UITableView. In storyboard I set the datasource and delegate. Here I am getting the error

17条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-29 03:22

    The answer of Ankit worked for me in Xcode 8 for Swift 2.3. Here’s the new syntax.

    extension ViewController: UITableViewDataSource {
        internal func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
            //return 1
        }
    
        internal func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
            //return cell
        }
    }
    

提交回复
热议问题