Reputation: 6049
In the storyBoard "parent" scene with its parentVC.swift, there is a containerView with embedded segue with its containerVC.swift.
I am able to call containerView.myFunc() in the parentVC viewDidLoad() with no problems.
How can I call a custom func defined in parentView from an action of a button in containerView.
self.parentViewController.myCustomFunc()
I get
Value of type UIViewController? has no member myCustomFunc
Upvotes: 0
Views: 1090
Reputation: 31026
You need to cast parentViewController
so the compiler knows which functions are available. The definition is simply UIViewController?
which, as the error says, doesn't have your function.
Try:
if let vc = self.parentViewController as? parentVC {
vc.myCustomFunc()
}
Upvotes: 1