thinking in swift
TRANSCRIPT
![Page 1: Thinking in Swift](https://reader035.vdocument.in/reader035/viewer/2022070513/58b88bab1a28ab3e3a8b49cf/html5/thumbnails/1.jpg)
Thinking in Swift
![Page 2: Thinking in Swift](https://reader035.vdocument.in/reader035/viewer/2022070513/58b88bab1a28ab3e3a8b49cf/html5/thumbnails/2.jpg)
Classes
![Page 3: Thinking in Swift](https://reader035.vdocument.in/reader035/viewer/2022070513/58b88bab1a28ab3e3a8b49cf/html5/thumbnails/3.jpg)
Problems with classes
• Implicit sharing• Class inheritance is too intrusive• Lost type relationships
![Page 4: Thinking in Swift](https://reader035.vdocument.in/reader035/viewer/2022070513/58b88bab1a28ab3e3a8b49cf/html5/thumbnails/4.jpg)
Protocol Oriented Programming
https://developer.apple.com/videos/play/wwdc2015/408/
![Page 5: Thinking in Swift](https://reader035.vdocument.in/reader035/viewer/2022070513/58b88bab1a28ab3e3a8b49cf/html5/thumbnails/5.jpg)
Protocol Oriented Programming
• Protocols are more flexible• Structs are lightweight• Protocol extensions• Retroactive modelling
![Page 6: Thinking in Swift](https://reader035.vdocument.in/reader035/viewer/2022070513/58b88bab1a28ab3e3a8b49cf/html5/thumbnails/6.jpg)
MVC
![Page 7: Thinking in Swift](https://reader035.vdocument.in/reader035/viewer/2022070513/58b88bab1a28ab3e3a8b49cf/html5/thumbnails/7.jpg)
Model - View - View Model
![Page 8: Thinking in Swift](https://reader035.vdocument.in/reader035/viewer/2022070513/58b88bab1a28ab3e3a8b49cf/html5/thumbnails/8.jpg)
Functional Reactive Programming
Streams
Transformations
Bindings
![Page 9: Thinking in Swift](https://reader035.vdocument.in/reader035/viewer/2022070513/58b88bab1a28ab3e3a8b49cf/html5/thumbnails/9.jpg)
RXSwift
• Observable• Variable• Driver• bindTo
![Page 10: Thinking in Swift](https://reader035.vdocument.in/reader035/viewer/2022070513/58b88bab1a28ab3e3a8b49cf/html5/thumbnails/10.jpg)
Objective-C libraries
![Page 11: Thinking in Swift](https://reader035.vdocument.in/reader035/viewer/2022070513/58b88bab1a28ab3e3a8b49cf/html5/thumbnails/11.jpg)
Networking library
• Based on NSURLConnection• No dependency on Objective-C• Not complex requirements• To try something new
![Page 12: Thinking in Swift](https://reader035.vdocument.in/reader035/viewer/2022070513/58b88bab1a28ab3e3a8b49cf/html5/thumbnails/12.jpg)
Networking
Start with a protocol
protocol HTTP { func executeRequest(request: Request) -> Result<Response, NSError>}
![Page 13: Thinking in Swift](https://reader035.vdocument.in/reader035/viewer/2022070513/58b88bab1a28ab3e3a8b49cf/html5/thumbnails/13.jpg)
Demo
• Table views• Protocols• HTTP client
![Page 14: Thinking in Swift](https://reader035.vdocument.in/reader035/viewer/2022070513/58b88bab1a28ab3e3a8b49cf/html5/thumbnails/14.jpg)
Finishing thoughts• More expressive• Less bugs• Better testing• Different• Fun