Swift short tour - Interesting language

32
1 Trinh Nguyen 2014.12.11

Transcript of Swift short tour - Interesting language

Page 1: Swift short tour - Interesting language

1

Trinh Nguyen

2014.12.11

Page 2: Swift short tour - Interesting language

2

Page 3: Swift short tour - Interesting language

3

The previous WWDCs WWDC 2014

Page 4: Swift short tour - Interesting language

4

WWDC 2014

Page 5: Swift short tour - Interesting language

5

Page 6: Swift short tour - Interesting language

Objective C

//ex1

CGPoint aPoint = CGPointMake(9.0, 10.0);

//ex2

UIView *aView = [[UIView alloc] init];

6

Page 7: Swift short tour - Interesting language

And Swift

//ex1

let aPoint = CGPointMake(9.0, 10.0)

//or equivalently:

let aPoint: CGPoint = CGPointMake(9.0, 10.0)

//ex2

var aView = UIView()

//or equivalently:

let aView: UIView = UIView()

3 characters

7

Page 8: Swift short tour - Interesting language

And Swift

//ex1

let aPoint = CGPointMake(9.0, 10.0)

//or equivalently:

let aPoint: CGPoint = CGPointMake(9.0, 10.0)

//ex2

var aView = UIView()

//or equivalently:

let aView: UIView = UIView()

3 characters

8

Swift performs type checks when compiling your

code and flags any mismatched types as errors. This

enables you to catch and fix errors as early as

possible in the development process.

Page 9: Swift short tour - Interesting language

; 9

Page 10: Swift short tour - Interesting language

; 10

Page 11: Swift short tour - Interesting language

11

Page 12: Swift short tour - Interesting language

12

Page 13: Swift short tour - Interesting language

13

Page 14: Swift short tour - Interesting language

Swift comes with many features to make your

code fairly human readable:

• Closures unified with function pointers

• Tuples and multiple return values

• Generics

• Fast and concise iteration over a range or collection

• Structs that support methods, extensions, protocols.

• Functional programming patterns.

14

Page 15: Swift short tour - Interesting language

15

Page 16: Swift short tour - Interesting language

16

Page 20: Swift short tour - Interesting language

20

Page 21: Swift short tour - Interesting language

21

Page 22: Swift short tour - Interesting language

22

Page 23: Swift short tour - Interesting language
Page 24: Swift short tour - Interesting language

24

Page 25: Swift short tour - Interesting language

25

Page 26: Swift short tour - Interesting language

26

Page 28: Swift short tour - Interesting language

28

Page 29: Swift short tour - Interesting language

29

Page 30: Swift short tour - Interesting language

30

Page 31: Swift short tour - Interesting language

31

Page 32: Swift short tour - Interesting language

Q - A

32