架构(Architecture)

A collection of 8 posts
MVVM 架构|协调 Service 层与Manager 层
架构(Architecture)

MVVM 架构|协调 Service 层与Manager 层

在使用 MVVM 架构的 Swift 项目,可以抽象出 MVVM 核心层和支持层。 * 核心层包含基本的 Model、View 和 ViewModel。 * 支持层包含 Service、Manager 和其他工具类(Utilities)。 一个完整的项目结构是这样: 在涉及 SwiftData 的功能模块,会更复杂一些。 Manager 和 Service 的协调关系 Service > Manager 典型的调用链路: View → ViewModel → Service → Manager → 外部资源 Service 层级高于 Manager,在 Service 调用多个 Manager。 在 ViewModel 中调用 Service * 避免在 View 中直接调用
5 min read