ios - 如何导致模型更新以快速触发另一个 Controller 中的更新

标签 ios swift model-view-controller

View Controller A 可以访问模型并可以改变模型。 View Controller B 显示模型。我想要当 View Controller A 更新模型时,在 View Controller B 中触发一个方法,以便更新 View 。在 Swift 中是否有标准的方法来执行此操作?

最佳答案

在这个变量的 didset 中,你可以发布一个通知,另一个 Controller 可以注册这个通知。 (我们可以根据需要做的更整齐。)

关于ios - 如何导致模型更新以快速触发另一个 Controller 中的更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41411504/

相关文章:

ios - iOS 在 Web View 中加载 html 文件时屏幕黑屏

android - 从 3.4 更新到 cordova 5.1 后无法获取 appView

objective-c - 如何在没有 namespace 的 Objective-C 中划分类?

inheritance - Swift 协议(protocol)继承和泛型函数

swift - replaykit 是否允许录制屏幕然后播放屏幕?

javascript - backbone.js:如何对模型的属性进行内联编辑

ios - 使用 xib 自定义标注 View

ios - "Communications error"- AVFoundation 相机

model-view-controller - 路由到 Play 中的静态文件!框架2.0

c++ - Qt:Qt 新手问题