您的位置:首页 > 移动开发 > IOS开发

第一讲:iOS概述

2015-02-02 09:53 411 查看
一、什么是iOS?

1、Core OS(核心操作系统层),这是很接近硬件的一层,是一个Unix内核;

2、Core Services(核心服务层),这是之上的面向对象的一层 

3、Media(媒体层) 

4、Cocoa Touch(UI层)

二、Platform
Components(平台组件) 

1、Tools:Xcode、Instrument(用于app代码分析,内存管理等) 

2、Language:Objective-c 

3、Frameworks:Foundation,所有核心服务都在这里(例如数组、字典);UIKit(例如按钮、滑动条);Core
Data,面向对象的数据库;Core Motion是陀螺仪和加速计;Map Kit显然是地图

三、设计策略(MVC)

1、controller
-> model:controller需要知道model的一切,还要有同model完全通信的能力。因为controller就是将model呈现给用户。controller需要能够完全、不受限制地访问model。

2、controller
-> view:view是controller的仆从,来布局用户界面这些。controller到view,通信也是不受限的。因为controller需要随意使唤自己的仆从。controller可以做任何事情。
outlet(出口):创建一个controller到view的outlet,这样controller就能同view通信。

3、model
<->
view:从不,模型完全独立于UI。

4、model
->
controller:这不允许,因为model对UI一无所知。有时,model中的数据发生变化,controller需要知道它(例如数据变化、数据库变化),这时就用到了notification和KVO。model发出通知,controller知道了model发生了变化,会让model把变化的数据给它。

5、view
->
controller

1>target、action;

2>will、should、did(代理、协议)

3>view中不会存储数据,view通过controller从model获取dataSource(其实是一种委托)。

四、strong和weak

Strong means keep the memory(内存)
for this,for the thing this points to,in the heap(堆),as long as I or anyone else has a strong pointer to it.So, this is called reference counting(这被叫作引用计数). 

If you have a weak pointer,that tells objective-C,
I have a pointer to this thing in the heap and keep it in memory as long as someone else has a strong pointer to it.But as soon as no one else has a strong pointer to that thing, it gets freed from memory.And this pointer, if it was weak,gets set to nil.Nil
means this pointer doesn't point to anything.Nil is the same as zero.In objective-C,you can send message to nil pointers even and it will not crash your program.

五、nonatomic

Nonatomic
means calling this setter and getter that go along with this property is not thread(线程) safe.So you can't have two threads trying to set this property at the same time.The way we do multithreading(多线程)
is iOS,is not by having a single object that multiple threads are setting on(不是一个对象上多个线程在设置),we usually have a separate set of objects(另外一组对象) that are running in another thread,like your model.UI stuff(UI这些东西) is running in the UI thread,and they're talking
thread to thread.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: