1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Call function of child view instance from parent view controller

Discussion in 'Programming/Internet' started by Andreas Schultz, Sep 12, 2018.

  1. I have a motherView controlled by motherViewController with a container view in it. The container view is controlled by an childViewController. The childView holds an tableView.

    Now I have a cleanTableView function in the childViewController, which "resets" the tableView when called.

    func clean() {
    let indexPath = IndexPath(row: 0, section: 0)
    if let cell = tableView.cellForRow(at: indexPath) {
    if cell.accessoryType == .checkmark {
    cell.accessoryType = .none

    In my motherView there is a button. When this button is touched it calls an action on motherViewController.

    @IBAction func cancelButtonTapped(_ sender: UIBarButtonItem) {

    //call clean method of containerView instance


    How do I call, from this action, the cleanTableView function on the specific childView Instance?

    Login To add answer/comment

Share This Page