appsquickly / typhoon

Powerful dependency injection for Objective-C ✨✨ (https://PILGRIM.PH is the pure Swift successor to Typhoon!!)✨✨
https://pilgrim.ph
Apache License 2.0
2.7k stars 269 forks source link

Auto injection not work? #472

Closed ampilogov closed 8 years ago

ampilogov commented 8 years ago

I try use Auto injection, but property was not inject.

MainAssembly.m:

- (Car *)car
{
    return [TyphoonDefinition withClass:[Car class] configuration:^(TyphoonDefinition *definition) {
        [definition useInitializer:@selector(init) parameters:^(TyphoonMethod *initializer) {
            [definition injectProperty:@selector(model) with:@"BMW"];
        }];
    }];
}

Create ViewController :

TestViewController *testVC = [[TestViewController alloc] init];
[self.navigationController pushViewController:testVC animated:YES];

TestViewController.h

#import <UIKit/UIKit.h>
#import "TyphoonAutoInjection.h" 

@interface TestViewController : UIViewController
@property (strong, nonatomic) InjectedClass(Car) car;
@end

_Finally property car_ wasn't inject. **

P.S. If I use Storyboard, it work

jasperblues commented 8 years ago

If you're not using Storyboards you have to create a definition for your view controller and resolve it from Typhoon. The Typhoon sample for swift of objc shows how to do this.