ios - 不同组件如何在iOS的MVVM中通信

标签 ios objective-c model-view-controller mvvm communication

知道在典型的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/

相关文章:

android - PhoneGap 在后台上传数据

iphone - 如何在 iPhone 中加载高质量的 .gif 图像

iphone - 如何更改表格单元格详细信息披露按钮的颜色

java - 重构一个长 servlet 条件

java - Java MVC 模式可以与委托(delegate)模式结合吗?

objective-c - 从 subview 调用 View Controller 中的方法

ios - 禁用用户交互的 UITableViewCell 和 UITextField 不调用 didSelectRow

ruby-on-rails - AsyncTask :Class 的未定义方法 `handle_asynchronously'

ios - 如何使用 Parse TableView 传输图像

ios - 如何用 Storyboard 实现 RTPagingViewController?