知道在典型的MVC实现的iOS项目的Model, View 中,Controller将按照以下模式进行通信。
使用IBActions,委派给 Controller 的 View
使用直接方法调用或使用块进行回调的 Controller 进行建模
使用委派或KVO建模到 Controller
Controller 以使用IBOutlets查看
如果我在任何地方错了,请纠正我。
我的问题是,在典型的MVVM实现的项目中这将如何发生。我想要组件之间的最佳通信方法,并请说明如果某种东西具有不止一种通信可用性的方式,那么某个特定的方法比其他方法更好。 callBacks)最适合与Call backs一起使用,以获得更精确和可读的代码。
我也将给那些给我最好答案的人投票。
最佳答案
数据流描述了MVVM中元素的通信:
Data Flow
1. UI calls method from ViewModel (Presenter).
2. ViewModel executes Use Case.
3. Use Case combines data from User and Repositories.
4. Each Repository returns data from a Remote Data (Network), Persistent DB Storage Source or In-memory Data (Remote or Cached).
5. Information flows back to the UI where we display the list of items.
本文中有MVVM的更详细描述
https://tech.olx.com/clean-architecture-and-mvvm-on-ios-c9d167d9f5b3
关于ios - 不同组件如何在iOS的MVVM中通信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36593135/