Skip to main content
added 48 characters in body
Source Link
malhal
  • 29.6k
  • 7
  • 119
  • 144

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.

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 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.

added 199 characters in body
Source Link
malhal
  • 29.6k
  • 7
  • 119
  • 144

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 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.

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;

Source Link
malhal
  • 29.6k
  • 7
  • 119
  • 144

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.