Programming in iOS with Objective-C Using MVC
今天开始学习Stanford University 的公开课 —– CS193P iPhone Development Course by Stanford University。 此博文主要记录MVC相关的基础知识。
MVC not a programming language ,not a platform . It is a Software Architecture Design Pattern.
MVC is the Blueprint of a software development project.
MVC is abbreviated to Model ,View ,Controller .
Objective-C is built upon MVC Design pattern. Apple expects all the iOS programmers to follow this programming architecture pattern.
What is MVC ?
Model – What your application is about? (Data,Logical ,Rules)
Controller – How you present your application (model) to the end users?
View – The interface which the end users see.
How they interact with each other ?
View 没有数据;View 只能通过controller和model进行数据交互;Controller 能够直接与View 和Model 进行交互。下面一张来自apple官方的介绍MVC如何交互的图片:
View 可以通过如下方式和Controller 进行交互:
a. Target-Action (eg: buttons)
b. Delegate (Will, Did, Should)
c. Data Source (data at, count)
**重点内容**Model 只能通过下面的两种方法与Controller 进行交互:
a. Notifications
b. KVO (Key-Value Observing)
Advantages of MVC ?
IOS Four Layer
Core OS
Core Services
Media
Cocoa Touch