I got those errors using swift in Xcode Version 9.2 (9C40b)
- Binary operator '*' cannot be applied to operands of type 'IndexPath' and 'Float'
- Ambiguous reference to member 'tableView(_:numberOfRowsInSection:)'
@IBOutlet weak var slider: UISlider!
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 50
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "Cell")
cell.textLabel?.text = String(indexPath * slider.value)
return cell
}
@IBAction func sliderValueChange(_ sender: Any) {
tableView.reloadData()
}
Try this :
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "Cell")
cell.textLabel?.text = String(slider.value * Float(indexPath.row))
return cell
}