I recommend using the typhoonDidInject callback method
typhoonDidInject() -> Void {
myObject.delegate = self;
}
or if you don't wish to couple directly to Typhoon, specify a custom one in the assembly:
definition.performAfterInjections("someMethod")
I can't think of a neater way to wire all of this up in the assembly, however if you would like to make a suggestion of what it should look like, we could implement that.
Edit:
If you wanted to wire all of it up with Typhoon, you could provide something like:
- (UIViewController *)someViewController
{
return [TyphoonDefinition withClass:[FoobarViewController class]
configuration:^(TyphoonDefinition *definition) {
[definition injectProperty:@selector(machine)
with:[self spaghettiMachine]];
[definition performAfterInjections:@selector(injectSpaghettiMachine:with:)
parameters:^(TyphoonMethod *method) {
[method injectParameterWith:[self spaghettiMachine]];
//This will be the same object for any scope except 'Prototype'
[method injectParameterWith:[self someViewController]];
}];
}];
}
- (SpaghettiMachine *)spaghettiMachine
{
return [TyphoonDefinition withClass:[SpaghettiMachine class]
configuration:^(TyphoonDefinition *definition) {
definition.scope = TyphoonScopeWeakSingleton;
}];
}
But this would still require that each of your view controller implement a method something like:
- (void)injectSpaghettiMachine:(SpaghettiMachine *)machine
with:(id)delegate
{
machine.delegate = self;
}
. . the above might be useful if the controllers have a common base class.