Objection基本原理
阿新 • • 發佈:2017-06-23
navi dex https jsb logs implement efault 默認 center
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];
}}
Objection基本原理