0
votes

I am loading view controllers from TyphoonStoryboard and have a definition for the class which works fine, several properties are injected with no problems. However one of the properties is a view which itself has a delegate property which I want to be the view controller instance. When the view comes to set the delegate property it tries to create a new instance of the view controller instead of using the instance which has been created by the storyboard. How can I make the delegate property use the current instance of the view controller? My definitions look something like this:

- (id)viewController
{
  return [TyphoonDefinition withClass:[MyViewController class]     
    configuration:^(TyphoonDefinition *definition) {
    [definition injectProperty:@selector(view) with:[self myView]];
  }];
}

- (id)myView
{
    return [TyphoonDefinition withClass:[MyView class]         
    configuration:^(TyphoonDefinition *definition) {
        [definition injectProperty:@selector(delegate) 
           with:[self viewController]];
    }];
}

From what I can see the view controller can never be used a reference as it doesn't added a shared reference anywhere and Typhoon has no option but to instantiate a new one?

1

1 Answers

0
votes

This was not supported prior to Typhoon 2.3.4. Prior to this version, objects created outside of Typhoon did not participate in scope pools. Therefore, its not possible to wire delegate to viewController with Typhoon, but you could wire in Interface Builder or use a performAfterInjections callback.

As of 2.3.4, objects instantiated outside of Typhoon, but subsequently injected, participate in the scope pools, therefore circular dependencies work as expected.