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

后端 未结 17 2613
旧巷少年郎
旧巷少年郎 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:30

    In general, a protocol has optional and required methods. For example, UISearchBarDelegate and UITableViewDelegate are the cases that you can declare to conform to a protocol without implementing any of their methods. But it does not work fine for UITableViewDataSource.

    In the official documentation, Protocol "UITableViewDataSource" -> Symbols -> Configuring a Table View, the methods: func tableView(UITableView, cellForRowAt: IndexPath) and func tableView(UITableView, numberOfRowsInSection: Int) shown with bold Required key word.

提交回复
热议问题