1

I have a tableViewCell inside which I have a TableView which in turn has a tableViewCell. How do I access the innermost tableView and tableViewCell to add data to it?. I am trying to do something like a facebook comment page.

Any help will be appreciated. Thank you.

1 Answers1

0

You can do in this way:

class mainTableViewController: UITableViewController {
    //your functions here
}

//your custom cell class

class yourCustomCell:UITableViewCell,UITableViewDataSource,UITableViewDelegate{
    @IBOutlet weak var innerTableView : UITableView?
    var myArray : Array<Any> = []
    override func awakeFromNib() {
        super.awakeFromNib()
        innerTableView?.dataSource = self
        innerTableView?.delegate = self
    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return myArray.count
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = UITableViewCell.init(style: .default, reuseIdentifier: "identifier")
        return cell
    }
}
Codobux
  • 1,028
  • 1
  • 12
  • 15