I'm having trouble understanding what this error means. My app was working fine until I migrated up to Swift 4. Now I'm getting this tableView:numberOfRowsInSection error when trying to open several of my view controllers. I didn't get any of these errors in Swift 3.2. The numberOfRowsInSection method has been implemented in all cases, and appears fine. Can anyone point me in the right direction?
2017-11-26 10:21:04.973523-0600 Y2GOsp[27701:6382461] -[Y2GOsp.ClientDetailViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x7fa51c89f000 2017-11-26 10:21:43.328635-0600 Y2GOsp[27701:6382461] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Y2GOsp.ClientDetailViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x7fa51c89f000'
numberOfRowsInSection implementations:
Example 1:
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
Example 2:
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return dayAppoints.count
}
numberOfRowsInSectionimplementation to the question. - vacawamatableview:…instead oftableView:…? - vikingosegundo@objcbefore the func declaration make it work? - vacawamaUITableViewDataSource? If it does, Swift should infer (and require) that your implementation(s) of the@objcprotocol requirements are also@objc. It would help if you could provide some more context. - Hamish