Dmytrii G.
Dmytrii G.

Reputation: 547

How get access from UIViewController, which is a containerView in other UIViewController?

I has two UIViewControllers. SecondViewController is a ContainerView in FirstViewController.

I know how get access from First to Second, but have no idea how to do this opposite(Second to First). Maybe anyone knows how I can try to do this.

Thanks for all answers and ideas!

Upvotes: 1

Views: 36

Answers (3)

Andrey Volobuev
Andrey Volobuev

Reputation: 968

You can set FirstViewController as a delegate for SecondViewController

Upvotes: 0

rmickeyd
rmickeyd

Reputation: 1551

You can access the view controller by using the parent property.

   if let vc = parent as? FirstViewController {
        }

Upvotes: 1

NRitH
NRitH

Reputation: 13903

If SecondViewController is properly set up as a contained (i.e. child) view controller, then its parent property will point to FirstViewController.

Upvotes: 1

Related Questions