How to set the delegate of the original ViewController in the storyboard

I have a storyboard:

-- initial --> [PictureListViewController] ----> [PictureDetailViewController] 

Now I want to set the delegate of my ViewController PictureListViewController . Since this is the first ViewController, I cannot do this in the method -(void)prepareForSegue:... , since I am the initial ViewController created by the Storyboard infrastructure.

For reuse, I also don't want the PictureListViewController set its own delegate .

What is the best practice for this. I could, of course, create another “empty” ViewController, which then goes to the PictureListViewController , but that doesn't seem to be the right thing for me.

Your help is greatly appreciated. Thanks: -)

+4
source share
1 answer

You can set this in the App Delegate by grabbing a link to your root view controller using ...

 YourFirstViewController *ctr = self.window.rootViewController; // Do stuff here 
+5
source

Source: https://habr.com/ru/post/1385539/


All Articles