ProtocolServiceManger
简单高效的 Protocol<=>Service
示例
要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install
。
- AccountBusiness <=> PlayBusiness
VIP和播放业务复杂后,只公开Protocol文件决定业务对外能力
组件交互:从VIP业务来校验当前用户是否VIP,进而决定是否可以触发播放业务执行播放
Class <LFLVipProtocol> vipService = ServiceClassWithProtocol(LFLVipProtocol);
if (vipService && [vipService isCurrentUserVipStatus]) {
Class <LFLPlayProtocol> playService = ServiceClassWithProtocol(LFLPlayProtocol);
[playService playMiniVideo];
} else {
NSLog(@"Error:LFLVipProtocol notfound service Class");
}
-
如果对外业务能力未实现,则在编译期触发断言,便于发现问题。
-
推荐约定
-
XXX
Service -
XXX
Protocol
-
安装
ProtocolServiceManger 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中:
pod 'ProtocolServiceManger'
作者
DevdragonLi, [email protected]
许可协议
ProtocolServiceManager 以 MIT 许可协议提供。更多信息请参阅 LICENSE 文件。