I tried this but not worked Iterate over all the UITableCells given a section id I need to just iterate a for loop in cell and calculate the value and display in another label calculated_value or print I dont know how to do it. Any help will be great! I got only value for cell I see the cell which are at bottom there value is not calculated. when I scroll up I get the cell value but then the top cell value is not able to see or calculate.
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource{
let news = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return news.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = myTableView.dequeueReusableCell(withIdentifier: "mycellTVC") as! mycellTVC
cell.lbl.text = news[indexPath.row]
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 80
}
@IBOutlet weak var myTableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
myTableView.delegate = self
myTableView.dataSource = self
}
}
**This is my cell file**
class mycellTVC: UITableViewCell{
@IBOutlet weak var lbl: UILabel!
@IBOutlet weak var calculated_value: UILabel!
}