Developing iOS 8 Apps with Swift 学习笔记

iOS MVC学习记录


1、MVC(Model-View-Controller):Model = What yourapplication is(but not how it is displayed). Controller = How your Model ispresented to the user (UI logic),the controller controls how the model ispresented on screen. View = Your Controller's minions. The stuff in thecontroller is very specific to how your UI works. The stuff in the model iscompletely independent of how your UI works.


2、The controller has to know everythingabout the model, and it has to have complete ability to talk to the model, useits public API as much as it wants, because the controller's job is to presentthe model to the user using its view as its minions.


3、When we have a property of a controllerthat points into the view, we call it an outlet. View objects are generic. They can't really know much about thecontroller. They only communicate back to the controller in a blind way wherethey don't know the class of the thing they are talking to, and in a structuredway. Target-Action: the controller basically drops a target on itself, and thenit hands out an action, which is like an arrow, to the view and says to theview, when you do what you do, like you're a button and someone touches you oryou’re a slider and someone moves you, send me that action.


4、Sometimes the view, things are happeningin the view that are somewhat complicated, and the controller needs to beinformed of what's going on, synchronizing what's happening. And one way to think about this is thesewords I put up here, will, should and did. These things, the view itself mightnot have enough logic to know the answer to those questions. So what it doesis, it delegates the authority to answer those questions to some other object.The delegate is set via a protocol(i.e. it's "blind" to class).

 

5、Protocol is just a blind way to talk toanother object.

 

6、View should not own the data theydisplay. In other words, it shouldn't be a property inside of them. So ifneeded, they have a protocol to acquire it. Data source doesn't do the will didshould, it's gonna be asking questions like count etc. And the controller looks in the model.

 

7、Data source is just a kind of delegate,it's specific kind of delegate for getting data.

 

8、Apple 官方解释链接:https://developer.apple.com/library/ios/documentation/General/Conceptual/DevPedia-CocoaCore/MVC.html



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值