0

In my code I currently have a container view that embeds a storyboard reference. This storyboard that I'm referencing contains a view controller which contains two container views inside of it.

In my view controller with the container view, I gain access to my container view's view controller like so:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?)
{
    if segue.identifier == "showMetric" {
        guard let metricChildViewController = segue.destinationViewController as? MetricChildViewController else { return }
        var delegate: NewMetricDelegate!

        let type = MetricsType.watts
        let activityDelegate = NewActivityMetricDelegate(data: self.dataSet.dailySummary)
        activityDelegate.dailySummaryPresentationDelegate = metricChildViewController
        delegate = activityDelegate

        metricChildViewController.metricDelegate = delegate
        metricChildViewController.configure(type)
        //I want to gain access to the table view controller
    }
}

Here I am creating an instance of MetricChildViewController, which is the view controller embedded in my container view. Like I said before, MetricChildViewController contains two container views. I'm trying to configure it's table view controller.

What I thought of doing was including a prepareForSegue within my own prepareForSegue method in my view controller, to get access to my container view's viewController's container view, if that makes sense.

That doesn't seem like the best way of going about it, so I was wondering how I should go about this.

Chandresh Kachariya
  • 667
  • 2
  • 13
  • 31
Faisal Syed
  • 921
  • 1
  • 11
  • 25

1 Answers1

0

MetricChildViewController needs to have strong references to other containers. the easier way is to add MetricChildViewController as a child view controller instead of embedding it via storyboard

neprocker
  • 170
  • 5