到目前为止,我已经阅读了一些关于 iPhone 应用程序开发的 MVC 设计模式的资源。但是我有一个问题与 iPhone 开发环境中 MVC 的模型部分相关。
首先说一下我对MVC的看法,
模型: 与我们拥有的有关应用程序对象的数据相关。示例:火车模拟器的应用,每辆模拟火车都将拥有自己的属性,这些属性将保存在火车模型中。
Controller: 是控制 UI 更新的东西。它保留对火车模型的引用并检查模型中的任何更改,如果有则更改该特定火车的 View 。它会不断检查任何 UI 输入,以便它可以更改模型内的数据。
View :这是相当明显的, View 就是关于 UIView 的,我们在屏幕上看到的。
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/