Typhoon 中是否有可能在程序集文件中返回一个实例?
我想注入一个引用,AFHTTPRequestOperationManager
然后设置响应和请求序列化程序。
我想我可以做这样的事情:
- (AFHTTPRequestOperationManager*) httpRequestManager{
return [TyphoonDefinition withClass:[AFHTTPRequestOperationManager class] configuration:^(TyphoonDefinition * definition){
[definition useInitializer:@selector(initWithBaseURL:) parameters:^(TyphoonMethod * initializer){
NSURL * baseURL = [NSURL URLWithString:kPBAuthenticatorBaseURL];
[initializer injectParameterWith:baseURL];
}];
[definition performAfterInjections:@selector(setResponseSerializer:) parameters:^(TyphoonMethod * initializer){}];
[definition performAfterInjections:@selector(setRequestSerializer:) parameters:^(TyphoonMethod * initializer){}];
}];
}
是否没有简单的选项可以返回这样的实例:
- (AFHTTPRequestOperationManager*) httpRequestManager{
AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
//Do some stuff to register it in the graph object --> HELP?
}
这种方法是错误的吗?