Alex Smolov
Alex Smolov

Reputation: 1861

How do I add didSet to view property of UIViewController?

In my UIViewController, I would like to add code as soon as my view property is set:

var view:UIView! {
    didSet {
        //(view as MyView).delegate ...
    }
}

Obviously, it doesn't work because I cannot override variable of super class.

Is there any workaround to achieve what I want?

Upvotes: 0

Views: 547

Answers (1)

matt
matt

Reputation: 534958

The view will be set just once, and at that time viewDidLoad will be called. So go with the flow and override viewDidLoad and set the delegate there.

Upvotes: 1

Related Questions