如果可以使用匹配器根据协议选择定义,那就太好了,例如:
- (UIViewController *)viewControllerForViewModel:(id <IViewModel>)viewModel
{
return [TyphoonDefinition withOption:viewModel matcher:^(TyphoonOptionMatcher *matcher)
{
[matcher conformsToProtocol:@protocol(ILoginViewModel) use:[self loginViewController]];
[matcher conformsToProtocol:@protocol(IMainViewModel) use:[self mainScreenViewController]];
[matcher defaultUse:[self emptyScreen]];
}];
}
是否可以使用台风目前拥有的东西或某些解决方法?
谢谢。
编辑:
我对TyphoonOptionMatch和TyphoonOptionMatcher进行了一些补充,使它们具有conformsToProtocol选项,创建PR是否值得?
TyphoonOptionMatch
@property (nonatomic) Protocol *proto;
....
+ (id)matchWithConformsToProto:(Protocol *)proto injection:(id)injection;
TyphoonOptionMatcher
- (void)conformsToProto:(Protocol *)aProtocol use:(id)injection
...
- (TyphoonOptionMatch *)matchForValue:(id)value {
...
BOOL isConformProto = (match.proto && [value conformsToProtocol:match.proto]);
最佳答案
此功能已在3.4.5 release中列出
[matcher caseConformsToProtocol:@protocol(IMainViewModel)
use:[self mainScreenViewController]];
关于ios - TyphoonOptionMatcher与conformsToProtocol,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33939136/