斯坦福ios開發第一課:class logistics, overview of ios, MVC, Objective-C

Core OS: 

Mach是一個由卡內基梅隆大學開發的用於支持操作系統研究的操作系統內核。

BSD (Berkeley Software Distribution,伯克利軟件套件)是Unix的衍生系統,在1977至1995年間由加州大學伯克利分校開發和發佈的。

Core Services

Media

Cocoa Touch


Model=What your application is (but not how it is displayed)

Controller=How your Model is presented to the user (UI logic)

View=Your Controller's minions


控制器可以直接和模型和視圖對話

模型和視圖不能對話

控制器設置自身爲視圖的委託

委託通過協議設置

視圖通過協議獲取控制器的數據

模型不能直接和控制器對話

The Model is UI independent


Properties

通常情況下OC我們不直接訪問實例變量

The getter (usually) has the name of the property (e.g. "myValue:")

The setter's name is "set" plus capitalized property name (e.g. "setMyValue:")


strong,weak,nonatomic區別

strong:

keep the object that property points to in memory until I set this property to nil

weak:

if no one else has a strong pointer to this object, then you can throw it out of memory and set this property to nil.

nonatomic:

access to this property is not thread-safe. we will always specify this for object pointers in this course. If you do not, then the compiler will generate locking code that will complicate your code elsewhere.

BOOL的就不需要申明strong還是weak,因爲primitive types are not strored in the heap.不是指針


@synthesize:表示creates the backing instance variable that is set and gotten.

- (NSString *)contents{
    return _contents;
}

- (void)setContents:(NSString *)contents{
    _contents = contents;
}



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章