1,Objection 的简介
就是一个依赖注入框架,github地址:https://github.com/atomicobject/objection
2,Objection 原理
3,Objection 包括的模块
a, JSObjectionInjector 注册器
b,JSObjectionModule 模块
c, JSObjectionEntry 条目
d, JSObjectionUtils
4,用法
1.注册一个 注射器
@implementation Module + (void)load {
//默认注射器 JSObjectionInjector *injector = [JSObjection defaultInjector];
//没有就创建一个注射器 injector = injector ? : [JSObjection createInjector]; injector = [injector withModule:[[self alloc] init]]; [JSObjection setDefaultInjector:injector]; } - (void)configure { [self bindClass:[BViewController class] toProtocol:@protocol(BViewControllerProtocol)]; } @end
- (IBAction)btnClick:(id)sender {
JSObjectionInjector *injector = [JSObjection defaultInjector];
UIViewController <BViewControllerProtocol> *vc = [injector getObject:@protocol(BViewControllerProtocol)];
vc.backgroundColor = [UIColor redColor];
vc.currentIndex = 1000;
[self.navigationController pushViewController:vc animated:YES];
}}