gpt4 book ai didi

ios - Controller 如何实现通知功能?

转载 作者:行者123 更新时间:2023-11-29 03:32:53 25 4
gpt4 key购买 nike

我使用 MVC 模式。我有 UIViewCuctomViewControllerModelOfCuctomViewController

ModelOfCuctomViewController 为我的 CuctomViewController 创建数据并从某个网络服务器获取数据,因为我的延迟很小。问题是。我如何在更新 ModelOfCuctomViewController 后通知 CuctomViewController。

我现在正在使用KVC 模式来通知我的 Controller 模型中的一些变化。我可以使用 NSNotification。

也许,有人知道通知 Controller 的另一个选项功能吗?

最佳答案

我认为这样做的首选方法是使用 NSNotifications,但 KVC 或协议(protocol)/委托(delegate)也是不错的方法。我不认为 Apple 有什么特别的东西。

Communication: User actions in the view layer that create or modify data are communicated through a controller object and result in the creation or updating of a model object. When a model object changes (for example, new data is received over a network connection), it notifies a controller object, which updates the appropriate view objects.

关于ios - Controller 如何实现通知功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19543580/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com