iOS : 'MyViewController' does not conform to protocol 'UITableViewDataSource'

后端 未结 4 2195
广开言路
广开言路 2020-12-29 05:43
  • I am new to IOS swift development. I used to work with previous Xcode 6 beta.

  • I have downloaded the Xco

4条回答
  •  感动是毒
    2020-12-29 06:44

    You need to look at the whole error message. This specific message includes additional information about which methods are missing:

    Type 'MyViewController' does not conform to protocol 'UITableViewDataSource'
    Protocol requires function 'tableView(_:numberOfRowsInSection:)' with type '(UITableView, numberOfRowsInSection: Int) -> Int'
    Candidate has non-matching type '(UITableView!, numberOfRowsInSection: Int) -> Int'
    

    So... your numberOfRowsInSection takes an optional UITableView, and should take a required UITableView (this is a change they made between 6 and 6.1, all UITableView delegate and datasource methods now take required tableView and indexPath values)

提交回复
热议问题