国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

StanfordiOSLearnNotes-1

2019-11-14 18:36:20
字體:
來源:轉載
供稿:網友

這段時間在學習Stanford的iOS 8 的教學視頻,學而不思則怠,所以準備總結一下看視頻學習的一些筆記,便于自己加深理解。

吐槽一下就是現在的學習材料有好多英文的,又有好多中文的,雜亂到最后的結果就是,我自己也不知道某些英文用中文咋說,某些中文用英語咋說了……好凌亂……

現在已經學了6節課,從這六節課看,前三節課主要是講了一個Calculator的Demo,并穿插了很少一些iOS的介紹,以及MVC的介紹。第四節主要是介紹了一些Swift的語法,第五節和第六節主要講述了iOS的觸控操作(可能就是傳說中的Cocoa Touch),并且穿插了一些Swift的語法。因此,現在需要總結的內容分為三部分:

  1. 總結一下教授對iOS的簡介
  2. 總結一下教授在這六節課里面講的語法
  3. MVC,Cocoa Touch, Happiness Demo (這個在下面文章講吧。一篇筆記貼不完)

1. iOS簡介

iOS有四個層次構成:

  1. Core OS。 畢竟iOS是一個Operation system,這里提供了最基本的操作系統服務。
  2. Core Services。
  3. Media。 這是一個很重要的需要了解的層次。但是在Stanford的課程里面,教授說因為時間問題,他不會講這些。
  4. Cocoa Touch。 這是這節課主要集中的一個層次(layer)。也是開發一個簡單的App,最先接觸的層次。

iOS開發的一些相關需求:

  1. Tools: Xcode,Instruments (在Xcode中 cmd+i打開)
  2. Language: 毫無疑問這個課程集中于Swift,此外還要牽涉到Obj-c,畢竟Cocoa Touch Lib還是Obj-c的。
  3. Frameworks:Foundation,Core Data,UIKit,Core Motion,Map Kit  覺得教授只是說了這個課程里面會牽涉到的一些Frameworks
  4. Design Strategy: MVC (這在六節課里面,我覺得這個是最重磅的一個知識點了)

2. Swift語法

其實Swift的語法直接看Apple的Swift Language文檔就行了,但是覺得在課堂上聽到的,會理解的更直接一點。畢竟教授會立即把這些點用到Demo里面。在這六節課中,穿插的語法并不是特別多,主要有Optional Chain,Enum,Extension,PRoperty。這些語法的用法總結如下。

  1. Array, Dictionary
    1. 兩種定義方法。 Array<string>(), [string]()
  2. Computed properties (instance variables which are computed rather than stored) {set,get}
  3. switch
    1. switch varName { case value1 procedure1; case value2 procedure2; default procedure else;)
    2. case 中的var如果是enum,內部是可以定義變量的。這個是有enum的特性決定的。
  4. Functions as types
    1. if return is void, should declare the return value type as void still
  5. Closure syntax for defining functions “on the fly"
  6. Methods with the same name but different argument types
  7. Optional
  8. Range
    1. struct Rannge<T> {var startIndex:t var endIndex:T}
    2. An array’s range would be Range<Int>
    3. A string subrange is not Range<Int>,it’s Range<string.Index>
    4. … with ..<
  9. Enum
    1. Swfit里面的Enum很強大,可以有原始值(RawValue),這個和其他語言差不多。
    2. Swift的值可以有相關值,這是一個很強大的功能。
  10. Data Structures in Swift: Classes, Structures and Enumerations. Differences:
    1. Inheritance (class only)
    2. Introspection and casting (class only)
    3. Value type (struct, enum) vs reference type (class)
    4. For value type: you must note any fun that can mutate a struct/ enum with the keyWord mutating
  11. Method
    1. Override super clases method/var should has a keyword “override” before func/var
    2. A method can be marked final which will prevent subclass from being able to override.
    3. Classes can also be marked as final
    4. Both types and instances can have methods, declare a type method or property with a static keyword 
    5. Internal name vs External name
  12. Properties
    1. Property Observers, willset/didset
    2. One very common thing to do in an observer in a controller is to update the user-interface
    3. Lazy Initialization
  13. Initialization
    1. 對于struct,如果沒有init函數,那么會默認的給你加上一個init函數。參數為內部各個變量。
    2. Constant properties can also be set in init function.
    3. init機制非常復雜,光分析這個init機制估計就夠一篇文章了,這里就不詳細描述了。主要有convenience init,designated init。
    4. 我覺得主要的理解思路就是designate init側重于分配空間,初始化。convenience init側重于計算賦值。
    5. init函數的繼承機制。如果沒有實現任何designated inits,那么繼承所有的designated inits;如果沒有override所有的designated inits,那么繼承所有的convenience inits。如果沒有實現任何inits,那么繼承所有。
    6. Required inits
    7. Failable init
  14. AnyObject, introspection and casting (is and as)
    1. var cals = destinationViewController as CalculatorViewController. It will crash if the type is not compatible.
    2. var cals = destinationViewController as? CalculatorViewController. Return nil if the type is not compatible.
    3. if destinationViewController is CalculatorViewController, check if the type is compatible.
    4. The Array type could be casted also.
  15. Methods and Functions
  16. Type Conversion using init():
    1. let d = Int(2.3) //d=2
  17. Assertions: assert(()->Book, “message”). Asserts will be ignored for release.
  18. Objective-C compatibility:
    1. String vs NSString, Array vs NSArray, Dictionary vs NSDictionary and other Obj-C classes: NSObject, NSNumber, NSDate, NSData
  19. Property List,NSUserDefaults
    1. Property List is really just the definition of term.
    2. 從教授演示的Demo看,Property List就是一個約定俗成的變量,用來存儲Class內部的信息。這個變量一般用AnyObject實現,然后通過Cast,轉換成各種需要的信息。其中如果轉換,是自定義實現的。
    3. 存儲的原始類型必須為NSString,NSArray,NSDictionary,NSNumber,NSDate,NSData
    4. Property List的具體操作使用NSUserDefaults實現的。NSUserDefaults通過key來讀取或存儲Property List。具體的API這里就不總結了,以后遇到了具體總結一下這個用法吧。
  20. 接下來教授就講了View,我覺得就是Cocoa Touch框架吧(憑現有的知識,還不能確定。再另開一篇文章寫吧)。
  21. Extensions
  22. Protocols(就是interface啦,沒啥新鮮的東西。主要就是,可以知道必須由Class實現,如果不制定的話,可以更改內部的方法要價格mutating,對于一個var必須指定是只讀的,還是可以讀寫的)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 平昌县| 阳信县| 桐乡市| 赫章县| 延庆县| 原阳县| 拉孜县| 衡山县| 西华县| 泰州市| 壶关县| 富源县| 竹山县| 皮山县| 双鸭山市| 长兴县| 阿鲁科尔沁旗| 塘沽区| 景德镇市| 司法| 南安市| 望城县| 呈贡县| 五家渠市| 二连浩特市| 叙永县| 大渡口区| 芦山县| 阿拉善左旗| 扶沟县| 观塘区| 古丈县| 伊通| 定陶县| 甘泉县| 图们市| 广水市| 盐源县| 普兰县| 永丰县| 宁都县|