2011年6月16日 星期四

MVC ( Model , View , Controller) - Stanford CS193p Fall 2010

Cocoa Touch 是依據MVC概念設計的程式
Model : What your application is (but not how it is displayed) 存放應用程式的類別
View  : How your Model is presented to the user (UI logic) 組成使用者可以看見並互動的視窗
Controller : Your Controller’s minions 將模型與檢視連結在一起,也是決定如何處理使用者輸入的應用程式邏輯部分
Controller could talk with Model and also directly talk with View! But Model and View should never speak to each other! 

If View want to talk with Controller, Controller has set a target and then View give a action to the target! 
Controller會設一個目標給當View 發生Action 時觸發動作
The Controller sets itself as the View's delegate
Controller就如同受到View 的委派一樣去做些什麼.這些事情通常透過一個Protocol來通知
View利用 protocol 方法取的Controller的資料
View只用來展示使用者介面,部會自己有資料! 而資料通常在Controller上 而不會在Model上
Model 的溝通方法
Model 通常採用廣播的方式發佈消息, Controller只要設個接收器調對頻道就可以收到它的訊息, View也可以有接收器,不過通常不是用來收Model的消息
整個MVC回顧一下吧~
多個MVC合起來工作

沒有留言: