IOS | The difference between the approach to presenting a new ViewController and using Segue

I have a lot of confusion about the new screen presentation architecture in iOS. I can present the screen below two approaches.

1.By Creating a view controller object

UIStoryboard* sb = [UIStoryboard storyboardWithName:@"SecondStoryboard" bundle:nil]; MyViewController* myVC = [sb instantiateViewControllerWithIdentifier:@"MyViewController"]; // Configure the view controller. // Display the view controller [self presentViewController:myVC animated:YES completion:nil]; 

2. Make segue in the story board

I can do segue from the story bar to achieve the same

NOTE. I am considering a case where both ViewControllers are on the same storyboard. If both ViewControllers are on a different storyboard, then obviously we cannot use segue

Request: I am confused what the difference is in the above two approaches. When to use for good architecture. Is there a difference in memory consumption. Apple had to introduce segue for a specific purpose. Thank you in advance for sharing valuable knowledge.

+5
source share
1 answer

Try using segues where possible:

  • they greatly improve the understanding of the navigation structure of the application.
  • any memory overhead will be negligible compared to the memory used to instantiate the new view controller.
  • you can proceed to view controllers in other storyboards using storyboard links ( http://help.apple.com/xcode/mac/8.0/#/dev66c5f17da )
0
source

All Articles