你好,游客 登录 注册 搜索
背景:
阅读新闻

理解iOS的应用程序的MVC架构模式

[日期:2013-02-01] 来源:Linux社区  作者:mikixiyou [字体:大 中 小]

三、模型(Model)

模型方法通过数据源和数据含义等协议提供数据,需要实现由控制器触发的回调方法。你需要创建应用程序控制器触发的回调方法,并提供所需的任何委托协议的实现。iPhone SDK 中的数据源可以帮助实现。数据源指任何向另一个对象提供所需数据的对象,其类似于委托,必须在另一个对象中实现它们的方法。它与委托的不同之处在于创建或提供对象而不是针对用户交互作出反应。

苹果文档对于Data Source模式的定义如下:
A data source is almost identical to a delegate. The difference is in the relationship with the delegating object. Instead of being delegated control of the user interface, a data source is delegated control of data. The delegating object, typically a view object such as a table view, holds a reference to its data source and occasionally asks it for the data it should display. A data source, like a delegate, must adopt a protocol and implement at minimum the required methods of that protocol. Data sources are responsible for managing the memory of the model objects they give to the delegating view.

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款