0

I'm starting a new Swift project using Swinject without Storyboards. What's the pattern to inject ViewControllers into other ViewControllers to perform Segues?

  • If you inject a child ViewController into a parent ViewController, won't the child ViewController always be the same instance when you segue to it and back to the parent? I want to create a new one every time.
  • If you inject a child ViewController into a parent, won't that cause child ViewControllers of that child ViewController to also be injected, meaning you will get the entire app loaded into memory when you load the root ViewController?

Or am I missing something?

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Adam Young
  • 1,217
  • 10
  • 18
  • Without code it's very hard to answer you. Both of your questions depends on how you are implementing the hierarchy parent-children. – Giuseppe Lanza Jan 23 '17 at 09:48
  • Not sure what exacly you mean with "inject". In general, do what you normally see in Storyboard in code but without segues. Create `UINavigationController`, instantiate `UIViewController` and set it a `rootViewController`. Instead of seque, use `self.navigationController?.pushViewController(...)`. – shallowThought Jan 23 '17 at 10:11

0 Answers0