Swift short tour - Interesting language

Post on 20-Jul-2015

64 views 2 download

Tags:

Transcript of Swift short tour - Interesting language

1

Trinh Nguyen

2014.12.11

2

3

The previous WWDCs WWDC 2014

4

WWDC 2014

5

Objective C

//ex1

CGPoint aPoint = CGPointMake(9.0, 10.0);

//ex2

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

6

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

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.

; 9

; 10

11

12

13

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

15

16

20

21

22

24

25

26

28

29

30

31

Q - A

32