iphone - iPhone 开发环境中的 MVC

标签 iphone objective-c ios model-view-controller design-patterns

到目前为止,我已经阅读了一些关于 iPhone 应用程序开发的 MVC 设计模式的资源。但是我有一个问题与 iPhone 开发环境中 MVC 的模型部分相关。

首先说一下我对MVC的看法,

模型: 与我们拥有的有关应用程序对象的数据相关。示例:火车模拟器的应用,每辆模拟火车都将拥有自己的属性,这些属性将保存在火车模型中。

Controller: 是控制 UI 更新的东西。它保留对火车模型的引用并检查模型中的任何更改,如果有则更改该特定火车的 View 。它会不断检查任何 UI 输入,以便它可以更改模型内的数据。

View :这是相当明显的, View 就是关于 UIView 的,我们在屏幕上看到的。

enter image description here

Now, Question is...

Does Model has to be persistent to be considered as a Model? or I can have a Class which has variables without any persistency. Would that be considered as Model as well, Or Model must be stored somewhere like in CoreData or .Txt file etc....

感谢任何输入!

最佳答案

Does Model has to be persistent to be considered as a Model?

只要您的 Controller 可以支持,它可能会发生变化或变形。

Model must be stored somewhere like in CoreData or .Txt file

完全没有。

如果适用,您可以使用任何模型。模型只是您实际逻辑/数据库/网络访问/blablabla 的另一种抽象......

关于iphone - iPhone 开发环境中的 MVC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7843819/

相关文章:

ios - UITextField文本在自定义单元格中重复

ios - 如何将unix时间戳转换为NSData对象?

ios - 多个导航栏

ios - tableViewController 不同单元格中的不同图像无法正常工作

ios - 在 sqlite.swift 中创建多列索引

iphone - 最大且最常访问的 iPhone 开发论坛/论坛是什么?

iphone - 我想用 Quartz 将单色图像变成不同的颜色

iphone - 将静态字典数据添加到我的静态数组中

ios - 如何解决使用 iphone 4s、ipad 2 以 60fps 录制视频时出现的问题?

ios - UIWebView 和 NSURLConnection 共享 cookie 存储吗?