I'm using this in my MasterViewController
:
- (void)viewDidLoad {
[super viewDidLoad];
SceneDelegate *sceneDelegate = (SceneDelegate *)self.parentViewController.view.window.windowScene.delegate;
}
self.view.window
is nil at this point so I had to reach to the parent whose view has already been loaded and added to the window.
If you are using split view controller and the scene delegate is the split delegate then you could avoid the window/scene altogether and just do:
SceneDelegate *sceneDelegate = (SceneDelegate *)self.splitViewController.delegate;
I'm using this in my DetailViewController
.