I'm using a SwinjectStoryboard extension to set up injection for my main VC. That's working fine. I added the following to set up injection for another VC in the same storyboard. This view controller is reached by a segue from the initial view controller:
defaultContainer.storyboardInitCompleted(DetailViewController.self) { (r:Resolver, c:DetailViewController) in
c.bar = "Injected bar"
}
[I'm trying out SwinjectStoryboard with Xcode's default master/detail view app template, in case that's not obvious.]
Here's the thing: With the above code, injection works, but the closure is called twice with different instances of DetailViewController. The first is when setup() is called, and the second is when the DetailViewController appears on the screen. If I set a breakpoint in the closure, c is a different instance in the second call, and it's the second one that appears. I don't know why the first is created or what happens to it.
Why do I get two calls to this closure with different instances, and how would I avoid that?
I'm using a
SwinjectStoryboard
extension to set up injection for my main VC. That's working fine. I added the following to set up injection for another VC in the same storyboard. This view controller is reached by a segue from the initial view controller:[I'm trying out SwinjectStoryboard with Xcode's default master/detail view app template, in case that's not obvious.]
Here's the thing: With the above code, injection works, but the closure is called twice with different instances of
DetailViewController
. The first is whensetup()
is called, and the second is when theDetailViewController
appears on the screen. If I set a breakpoint in the closure,c
is a different instance in the second call, and it's the second one that appears. I don't know why the first is created or what happens to it.Why do I get two calls to this closure with different instances, and how would I avoid that?