ios(一)
先學習一下swift的內容
可以先找一些在線視頻大致瀏覽語言特性和xcode的使用,然後在官網上叠代式的學習
https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html#//apple_ref/doc/uid/TP40014097-CH5-ID309
這裏羅列了iOS開發常用的知識點,不用一下子學全,語言學習和iOS開發應該是相互促進,逐步學習的。
一、Declaring Constants and Variables
Type Annotations
var welcomeMessage: String
//can use keyword for variables
var `var` = 1.0
二、
three primary collection types, Array, Set, and Dictionary, as described in Collection Types.
三、function
define
無參、多參、多返回值的函數
func someFunction(argumentLabel parameterName: Int) {
}
返回值
func minMax(array: [Int]) -> (min: Int, max: Int)? {
if array.isEmpty
{ return nil }
else
{ return (12,13)}
}
Default Parameter Values
In-Out Parameters
Function parameters are constants by default.
func swapTwoInts(_ a: inout Int, _ b: inout Int) {
let temporaryA = a
a = b
b = temporaryA
}
Function Types
相當於函數指針
var mathFunction: (Int, Int) -> Int = addTwoInts
Every function in Swift has a type, consisting of the function’s parameter types and return type. You can use this type like any other type in Swift, which makes it easy to pass functions as parameters to other functions, and to return functions from functions.
四、枚舉類型
原來枚舉類型還有這麽多可以講的
raw value、關聯值、遞歸定義
五、類和結構體
六、protocol
note:良好的代碼風格,註意空格的位置
ios(一)