Swift4 Day46:CS193P|第二堂課

Alice
Alice
Aug 29, 2017 · 2 min read

2017.8.28

介紹MVC模式

Model View Controller 簡稱 MVC

Model:比如今天你的資料庫裡有一個資料表,該資料表上面有公司名稱、金流等等的資料,這些資料都可以把他存到 Model 裡面去,一個資料的匯集所。這意謂著,你從資料庫讀出來的每筆資料,都可以丟到Model裡面去做儲存。

View:是畫面呈現的意思。但是,我們要把他看做一個像是會做事的「人」,這個「人」專門負責幫我們處理外觀上的東西,像是會在main storyboard出現的東西。

Controller: Controller 的工作就是在做判斷,然後再呈現在View上。

把程式工作分區,當成程式變大時,比較好管理與抓錯。

這次利用上次做一半的計算機用MVC的模式實作,將計算的部分都寫在名為Calculator的File裡。

在實作中有提到幾個觀念:

struct跟class的差別mutatingenum

延伸閱讀

教學講義:https://goo.gl/K92BUc

教學github:https://goo.gl/dyJdKp

Daily Swift

Hi, I’m Alice. :-]

)

Alice

Written by

Alice

Swift addict, Taipei|wl02722691@gmail.com

Daily Swift

Hi, I’m Alice. :-]

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade