-1

I have been trying to pass data from Viewcontroller to UITableView custom cell using custom delegate.There are answers for passing data from Custom cell to ViewController but none for the viceversa .Can anyone suggest me with some idea or sample code.

Manishankar
  • 327
  • 1
  • 12

1 Answers1

0

I am not sure if this is what you mean, but you can set the data in function tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell

For example:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        let cell = tableView.dequeueReusableCell(withIdentifier: ViewController.cellIdentifier, for: indexPath) as! CustomCell
        cell.data = data 
        return cell

    }
Carien van Zyl
  • 2,853
  • 22
  • 30