https://goo.gl/328pSU
Chapter 1: Playground Basics Chapter 2: Variables and Constants Chapter 3: Numeric Types and Operations Chapter 4: Strings Chapter 5: Making Decisions Chapter 6: Repeating Steps Chapter 7: Functions Chapter 8: Optionals Chapter 9: Arrays Chapter 10: Dictionaries Chapter 11: Sets Chapter 12: Structures Chapter 13: Class Basics Chapter 14: Advanced Classes Chapter 15: Enumerations Chapter 16: Properties Chapter 17: Methods Chapter 18: Protocols Chapter 19: Protocol-oriented Programming Chapter 20: Error Handling Chapter 21: Advanced Error Handling Chapter 22: Generics Chapter 23: Functional Programming
Chapter 1: Playground Basics Chapter 2: Variables and Constants Chapter 3: Numeric Types and Operations
Chapter 1: Playground Basics Chapter 2: Variables and Constants Chapter 3: Numeric Types and Operations Chapter 4: Strings Chapter 5: Making Decisions Chapter 6: Repeating Steps Chapter 7: Functions Chapter 8: Optionals Chapter 9: Arrays Chapter 10: Dictionaries Chapter 11: Sets Chapter 12: Structures Chapter 13: Class Basics Chapter 14: Advanced Classes Chapter 15: Enumerations Chapter 16: Properties Chapter 17: Methods Chapter 18: Protocols Chapter 19: Protocol-oriented Programming Chapter 20: Error Handling Chapter 21: Advanced Error Handling Chapter 22: Generics Chapter 23: Functional Programming
Chapter 1: Playground Basics Chapter 2: Variables and Constants Chapter 3: Numeric Types and Operations
ch1
CPU RAM
Registry
ch1
CPUlet a = “Hello World” let myAge = 20 let yourAge = 30 let total = myAge+yourAge
compiler
ch1
0 4 2 3
以 10 進位⽽⾔,我們知道這個數字多⼤。
1000 100 10 1
1000 × 0 + 100 × 4 + 10 × 2 + 1 × 3Decimal:
ch1
1 1 0 1
擅⽤ 10 進位的我們,只好將數字改⽤ 2 進位表達
8 4 2 1
8 × 1 + 4 × 1 + 2 × 0 + 1 × 1Decimal:
ch1
8 4 2 1
bit bit bit bitbit bit bit bit
163264128
每 8 個 bit,我們稱為 1 個 byte
所以 1 個 byte 可以記到 255 這個數字
ch1
bit bit bit bitbit bit bit bit
bit bit bit bitbit bit bit bit
bit bit bit bitbit bit bit bit
bit bit bit bitbit bit bit bit
ch1
4,294,967,29511111111111111111111111111111111
寫這麼多 0 跟 1 是很繁瑣的,所以我們更常⽤ 16 進位表⽰
ch1
c 0 d e
1162564096
Decimal: 4096 × 12 + 256 × 0 + 13 × 16 + 1 × 14 = 43974
ch1
c 0 d e
1162564096
c
0
d
e
1 1 0 0
0 0 0 0
1 1 0 1
1 1 1 0
ch2
let number:Int = 10
為這筆資料取⼀個名字
ch2
let number:Int = 10
為這筆資料取⼀個名字
abc
ch2
let number:Int = 10
這筆資料可以存入整數
ch2
let number:Int = 10
在這筆資料存入整數 10
ch2
let number:Int = 10
這筆資料未來不能再變動內容
ch2
var number:Int = 10
這筆資料未來能再變動內容
ch2
var number:Int = 10
ch2
var number = 10
因為裡⾯存入 10,所以 Swift 知道這是 Int
ch2
有時候,某些資料要放在⼀起才有意義。
let coordinates: (Double,Double) = (2.1,3.5)
ch2
let coordinates: (Double,Double) = (2.1,3.5)
coordinates.0 —> 2.1coordinates.1 —> 3.5
ch2
let coordinates: (x:Double,y:Double) = (2.1,3.5)
coordinates.x —> 2.1coordinates.y —> 3.5
ch2
按住 Option 鍵後點擊變數或常數的名稱
ch3
let = 2+6 let = 10-2 let = 2*4 let = 24/3 let = 25%6
是的,你可以⽤中⽂當作變數/常數名稱
ch3
bit bit bit bitbit bit bit bit
0 0 0 10 0 0 0
ch3
bit bit bit bitbit bit bit bit
0 0 0 10 0 0
let = 1 << 3
0 0 0
let = 32 >> 2
ch3
let a = 0 a = a+1
let a = 0 a = a-1
ch3
let a = 0 a += 1
let a = 0 a -=1
ch3
let hourlyRate = 19.5 let hoursWorked = 10 let totalCost = hourlyRate * hoursWorked
ch3
let hourlyRate = 19.5 let hoursWorked = 10 let totalCost = hourlyRate * Double(hoursWorked)
ch3
let yes:BOOL = true let no = false
ch3
let doesOneEqualTwo = (1==2)false
ch3
let doesOneEqualTwo = (1==2)let doesOneNotEqualTwo = (1!=2)let doesOneGreaterThanTwo = (1>2)let doesOneLessThanTwo = (1<2)
ch3
let andTrue = (1<2) && (4 >3)
(1 ⼩於 2) ⽽且 (4 ⼤於 3)
ch3
let andFalse = (1<2) && (3>4)
(1 ⼩於 2) ⽽且 (3 ⼤於 4)
ch3
let orTure = (1<2) || (3>4)
(1 ⼩於 2) 或者 (3 ⼤於 4)
ch3
let orFalse = (1==2) || (3==4)
(1 等於 2) 或者 (3 等於 4)
ch3
let andTrue = true && truelet andFalse = true && false
let orTrue = true || falselet orFalse = false || false
Swifter .Taipei
2016.06.29 (Wed)PM19:30
2016.07.27 (Wed)PM19:30
Swifter .Taipeihttp://www.meetup.com/taipei-swifter/