Why the viewDidLoad() function runs in every NSViewController that are items of my NSTabViewController?

58 views Asked by At

At launch my macOS app presents an NSTabViewController with around 10 tabs in it. I have noticed that the viewDidLoad() function runs in all of these view controllers at launch.

But the Apple documentation says:

The tab view controller lazily loads the views associated with each child view controller, creating them only after the corresponding tab is selected. When the tab view controller’s view is first displayed, only the view for the initially selected tab is loaded.

In this way only the first (selected) view controller should call viewDidLoad(). Why do then all the child view controllers' viewDidLoad() gets called at launch?

Naturally, if I replace the viewDidLoad() with viewWillAppear() function in all the tabs, they get called only when switching to a specific tab.

One specific thing is that I use Realm and there is "import RealmSwift" in every of the child view controllers. Could that be a reason?

0

There are 0 answers