Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why TyphoonStoryboard crash on instantiateInitialViewController? #367

Closed
plandem opened this issue Jun 9, 2015 · 5 comments
Closed

why TyphoonStoryboard crash on instantiateInitialViewController? #367

plandem opened this issue Jun 9, 2015 · 5 comments

Comments

@plandem
Copy link
Contributor

plandem commented Jun 9, 2015

at my main assembly i have next method:

- (TyphoonStoryboard *)storyboardWithName:(NSString *)name {
    return [TyphoonDefinition withClass:[TyphoonStoryboard class] configuration:^(TyphoonDefinition* definition) {
        [definition useInitializer:@selector(storyboardWithName:factory:bundle:) parameters:^(TyphoonMethod *initializer) {
            [initializer injectParameterWith:name];
            [initializer injectParameterWith:self];
            [initializer injectParameterWith:[NSBundle mainBundle]];
        }];
    }];
}

and when i'm trying to create root controller:

-(UIViewController<LAThemeProtocol> *)rootViewController {
    return [TyphoonDefinition withParent:[self baseViewController] class:[UITabBarController class] configuration:^(TyphoonDefinition *definition) {
        [definition injectProperty:@selector(viewControllers) [self storyboardsInitialViewControllers]];
        definition.scope = TyphoonScopeSingleton;
    }];
}

it will crash on:

-(NSArray *)storyboardsInitialViewControllers {
    return @[
            [[self storyboardWithName:@"Diary"] instantiateInitialViewController]
    ];
}

with exception:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TyphoonDefinition instantiateInitialViewController]: unrecognized selector sent to instance 0x7a135090'
@plandem
Copy link
Contributor Author

plandem commented Jun 9, 2015

with common UIStoryboard everything works fine! What am i doing wrong?

-(NSArray *)storyboardsInitialViewControllers {
    return @[
           [[UIStoryboard storyboardWithName:@"Diary" bundle:[NSBundle mainBundle]] instantiateInitialViewController]
    ];
}

@plandem
Copy link
Contributor Author

plandem commented Jun 9, 2015

The main reason i'm trying to use TyphoonStoryboard - i want to inject property to each controller from 'storyboardsInitialViewControllers' after that.

@jasperblues
Copy link
Member

It looks the assembly is not activated. How are you bootrapping Typhoon? With plist integration (recommended with storyboards) or manaul?

@plandem
Copy link
Contributor Author

plandem commented Jun 9, 2015

Yes, it's injected via plist as first assembly:
https://www.dropbox.com/s/u8siei07qorturz/Screenshot%202015-06-09%2013.46.36.png?dl=0

and that code is at LAMainAssembly

@plandem
Copy link
Contributor Author

plandem commented Jun 9, 2015

ok, here is full list of that assembly. I still can't solve the problem and i need help:

#import "AppDelegate.h"
#import "LAMainAssembly.h"
#import "LAThemeAssembly.h"
#import "UIViewController+LATheme.h"
#import <MTLib/MTLogger+Crashlytics.h>
@implementation LAMainAssembly
-(AppDelegate *)appDelegate {
    [MTLogger startWithAPIKey:@"3d890e419a7370b528946bb4360f76c9afb317c7"];

    return [TyphoonDefinition withClass:[AppDelegate class] configuration:^(TyphoonDefinition *definition) {
        [definition injectProperty:@selector(window) with:[self mainWindow]];
        [definition injectProperty:@selector(theme)];
    }];
}

-(UIViewController<LAThemeProtocol> *)baseViewController {
    return [TyphoonDefinition withClass:[UIViewController class] configuration:^(TyphoonDefinition *definition) {
        [definition injectProperty:@selector(theme)];
    }];
}

-(UIWindow *)mainWindow {
    return [TyphoonDefinition withClass:[UIWindow class] configuration:^(TyphoonDefinition *definition) {
        [definition useInitializer:@selector(initWithFrame:) parameters:^(TyphoonMethod *initializer) {
            [initializer injectParameterWith:[NSValue valueWithCGRect:[[UIScreen mainScreen] bounds]]];
        }];

        [definition injectProperty:@selector(rootViewController) with:[self rootViewController]];
    }];
}

-(UIViewController<LAThemeProtocol> *)rootViewController {
    return [TyphoonDefinition withParent:[self baseViewController] class:[UITabBarController class] configuration:^(TyphoonDefinition *definition) {
        [definition injectProperty:@selector(viewControllers) with:[self storyboardsInitialViewControllers]];
        definition.scope = TyphoonScopeSingleton;
    }];
}

- (TyphoonStoryboard *)storyboardWithName:(NSString *)name {
    return [TyphoonDefinition withClass:[TyphoonStoryboard class] configuration:^(TyphoonDefinition* definition) {
        [definition useInitializer:@selector(storyboardWithName:factory:bundle:) parameters:^(TyphoonMethod *initializer) {
            [initializer injectParameterWith:name];
            [initializer injectParameterWith:self];
            [initializer injectParameterWith:[NSBundle mainBundle]];
        }];
    }];
}

-(NSArray *)storyboardsInitialViewControllers {
    return @[
            [[self storyboardWithName:@"Diary"] instantiateInitialViewController]
    ];
}
@end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants