Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typhoon Storyboard Integration

Tags:

typhoon

I am using a StoryBoard in my application. When I first started integrating Typhoon, I listed the Assemblies in the plist like so:

<key>TyphoonInitialAssemblies</key>
<array>
    <string>ApplicationAssembly</string>
    <string>CoreComponents</string>
</array>

This worked fine as I was injecting into the AppDelegate.

Now, if I need to inject into the various view controllers, it appears I have to remove the UILaunchStoryboardName and UIMainStoryboardFile from the application plist file, and use a TyphoonStoryboard like so:

- (BOOL)application:(UIApplication *)application 
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    NSString *storyboardName = ...
    TyphoonComponentFactory *factory = ...

    TyphoonStoryboard *storyboard = [TyphoonStoryboard 
        storyboardWithName:storyboardName factory:factory bundle:nil];

    self.window = ...
    self.window.rootViewController = [storyboard instantiateInitialViewController];
    [self.window makeKeyAndVisible];

    return YES;
}

However, I'm confused where I obtain the TyphoonComponentFactory. Since I already list the assemblies in the plist, can I somehow use that?

like image 389
Steve Avatar asked Feb 11 '23 18:02

Steve


1 Answers

it appears I have to remove the UILaunchStoryboardName and UIMainStoryboardFile from the application plist file, and use a TyphoonStoryboard like so

Incorrect. You can combine UIMainStoryboardFile (UILaunchStoryboardName) and TyphoonInitialAssemblies keys in your info.plist file.

In that case, created storyboard will be TyphoonStoryboard and has typhoon factory (created with specified in plist assemblies).

You can use storyboards exactly as you'd normally use them, with the added benefit that dependencies will also be injected, according to the definitions in your one ore more TyphoonAssembly classes.

like image 86
Aleksey Avatar answered Feb 14 '23 07:02

Aleksey