Slide 1

Slide 1 text

NETWORKING IN SWIFT FLEXIBLE sunshinejr thesunshinejr

Slide 2

Slide 2 text

Before Swift After WWDC’14 NETWORKING TIMELINE WWDC 2014 2 +

Slide 3

Slide 3 text

BEFORE SWIFT 3

Slide 4

Slide 4 text

NSURLCONNECTION AFNETWORKING NSURLSESSION 4

Slide 5

Slide 5 text

5

Slide 6

Slide 6 text

WITH SWIFT 6

Slide 7

Slide 7 text

NSURLSESSION ALAMOFIRE MOYA? 7

Slide 8

Slide 8 text

MOYA 8 https://github.com/Moya/Moya

Slide 9

Slide 9 text

9

Slide 10

Slide 10 text

EASY TESTING + FLEXIBILITY + OPTIONAL = + COMMUNITY 10

Slide 11

Slide 11 text

BASIC SETUP - TARGET + 11

Slide 12

Slide 12 text

BASIC SETUP - RUN! 12

Slide 13

Slide 13 text

MOYA+MAPPERS MOYA-OBJECTMAPPER MOYA-SWIFTYJSONMAPPER MOYA-ARGO MOYA-MODELMAPPER MOYA-GLOSS MOYA-JASON 13

Slide 14

Slide 14 text

TIME FOR FLEXIN’ 14

Slide 15

Slide 15 text

PROBLEM 1: PASSING AUTH TOKEN 15

Slide 16

Slide 16 text

+ 16

Slide 17

Slide 17 text

PROBLEM 2: PASSING AUTH TOKEN … BUT SOMETIMES IN HEADERS … AND SOMETIMES IN PARAMETERS … AND SOMETIMES DON’T SEND IT AT ALL … AND SOMETIMES SEND GUEST TOKEN 17

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

+ + 19

Slide 20

Slide 20 text

+ 20

Slide 21

Slide 21 text

+ 20

Slide 22

Slide 22 text

+ 20

Slide 23

Slide 23 text

+ 20

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

PROBLEM 3: API WITHOUT API 22

Slide 26

Slide 26 text

SOLUTION: STUBS STUBS RECORDING + (warning: works only for simulator) 23

Slide 27

Slide 27 text

1. BASH SCRIPT 24

Slide 28

Slide 28 text

2. RECORDING PLUGIN 25

Slide 29

Slide 29 text

3. STUBBABLE TARGET TYPE 26

Slide 30

Slide 30 text

3. STUBBABLE TARGET TYPE 26

Slide 31

Slide 31 text

3. STUBBABLE TARGET TYPE 26

Slide 32

Slide 32 text

3. STUBBABLE TARGET TYPE 26

Slide 33

Slide 33 text

3. STUBBABLE TARGET TYPE 26

Slide 34

Slide 34 text

4. CONFORM TO NEW TARGET TYPE 27

Slide 35

Slide 35 text

4. CONFORM TO NEW TARGET TYPE 27

Slide 36

Slide 36 text

4. CONFORM TO NEW TARGET TYPE 27

Slide 37

Slide 37 text

4. CONFORM TO NEW TARGET TYPE 27

Slide 38

Slide 38 text

4. CONFORM TO NEW TARGET TYPE 27

Slide 39

Slide 39 text

5. ADD PLUGIN TO MOYA PROVIDER OR 28

Slide 40

Slide 40 text

QUESTIONS? https://github.com/sunshinejr/FlexibleMoya Code from slides at: More examples: https://github.com/Moya/Moya/tree/master/docs/Examples My Moya + RxSwift Networking tutorial: http://www.thedroidsonroids.com/blog/ios/rxswift-examples-3-networking/ sunshinejr thesunshinejr