SlideShare a Scribd company logo
Result pattern in Swift
VEDRAN BUROJEVIĆ

EMAIL: VEDRAN.BUROJEVIC@INFINUM.CO

TWITTER: @VBUROJEVIC
01HANDLING ERRORS IN SWIFT
👍

Swift error handling with try,
catch, do and throw works
nicely with synchronous code
🤔

But what about networking
calls which are asynchronous?
🚀



DEMO TIME
(NETWORKING WITHOUT RESULT PATTERN)
02RESULT PATTERN
HTTPS://GITHUB.COM/ANTITYPICAL/RESULT
Swift 2.0 introduces error handling via
throwing and catching ErrorType.

Result accomplishes the same goal by
encapsulating the result instead of
hijacking control flow.
RESULT DECLARATION
RESULT IS SIMILAR TO SWIFT’S OPTIONAL
HANDLING RESULT
You can use Result whenever
operation has a possibility of
failure
Infinum iOS Talks #4 - Making your Swift networking code more awesome with Result
You can even use Higher Order
Functions such as map and
flatMap
🚀



DEMO TIME
(NETWORKING WITH RESULT PATTERN)
💻



EXAMPLE REPO
https://github.com/vburojevic/ResultExample
📱🎉
THAT’LL BE ALL FOLKS!

THANKS FOR LISTENING!
Any questions?
VEDRAN.BUROJEVIC@INFINUM.CO
@BUROJEVIC
Visit infinum.co or find us on social networks:
infinum.co infinumco infinumco infinum

More Related Content

PDF
Elm view
PPTX
Typescript - a JS superset
PDF
JavaScript, un langage plein de promesses
PDF
Transpiler’s are here to stay
PDF
13 javascript techniques to improve your code
PDF
Introduction to React with MobX
PDF
Infinum Android Talks #20 - DiffUtil
PDF
Infinum Android Talks #20 - Making your Android apps fast like Blue Runner an...
Elm view
Typescript - a JS superset
JavaScript, un langage plein de promesses
Transpiler’s are here to stay
13 javascript techniques to improve your code
Introduction to React with MobX
Infinum Android Talks #20 - DiffUtil
Infinum Android Talks #20 - Making your Android apps fast like Blue Runner an...

Similar to Infinum iOS Talks #4 - Making your Swift networking code more awesome with Result (20)

PPTX
Knockout js with mvc
PPTX
Depurando VBScript no InduSoft Web Studio
PPTX
Unit 4 Java script.pptx
PPTX
Debugging VBScript in InduSoft Web Studio Projects
DOCX
Asynchronyin net
PDF
8.-Javascript-report powerpoint presentation
PDF
4007655 introduction-to-javascript
PDF
Javascript - Ebook (A Quick Guide)
PDF
Introduction to WAMP, a protocol enabling PUB/SUB and RPC over Websocket
PPTX
Single-page applications and Grails
PDF
Try! Swift Tokyo2017
PPTX
WebGL: The Next Generation
PDF
NodeJS for Novices - 28/Oct/13 - Winnipeg, MB
PPT
Griffon: Swing just got fun again
PDF
RxSwift for Beginners - how to avoid a headache of reactive programming
PPTX
Modern ASP.NET Webskills
PPTX
OpenDaylight Developer Experience 2.0
PDF
JavaScript Revolution - 5/Nov/13 - PrDC Saskatoon, SK
PPTX
WEBSOCKETS AND WEBWORKERS
PPT
JavaScript UI Architecture: Be all that you can be
Knockout js with mvc
Depurando VBScript no InduSoft Web Studio
Unit 4 Java script.pptx
Debugging VBScript in InduSoft Web Studio Projects
Asynchronyin net
8.-Javascript-report powerpoint presentation
4007655 introduction-to-javascript
Javascript - Ebook (A Quick Guide)
Introduction to WAMP, a protocol enabling PUB/SUB and RPC over Websocket
Single-page applications and Grails
Try! Swift Tokyo2017
WebGL: The Next Generation
NodeJS for Novices - 28/Oct/13 - Winnipeg, MB
Griffon: Swing just got fun again
RxSwift for Beginners - how to avoid a headache of reactive programming
Modern ASP.NET Webskills
OpenDaylight Developer Experience 2.0
JavaScript Revolution - 5/Nov/13 - PrDC Saskatoon, SK
WEBSOCKETS AND WEBWORKERS
JavaScript UI Architecture: Be all that you can be
Ad

More from Infinum (20)

PDF
Infinum Android Talks #20 - Benefits of using Kotlin
PDF
Infinum iOS Talks #4 - Making our VIPER more reactive
PDF
Infinum Android Talks #13 - Using ViewDragHelper
PDF
Infinum Android Talks #14 - Log4j
PDF
Infinum Android Talks #9 - Making your app location-aware
PDF
Infinum Android Talks #14 - Gradle plugins
PDF
Infinum Android Talks #14 - Facebook for Android API
PDF
Infinum Android Talks #19 - Stop wasting time fixing bugs with TDD by Domagoj...
PDF
Infinum Android Talks #18 - Create fun lists by Ivan Marić
PDF
Infinum Android Talks #18 - In-app billing by Ivan Marić
PDF
Infinum Android Talks #18 - How to cache like a boss by Željko Plesac
PDF
Infinum iOS Talks #2 - VIPER for everybody by Damjan Vujaklija
PDF
Infinum iOS Talks #2 - Xamarin by Ivan Đikić
PDF
Infinum iOS Talks #1 - Swift under the hood: Method Dispatching by Vlaho Poluta
PDF
Infinum iOS Talks #1 - Swift done right by Ivan Dikic
PDF
Infinum iOS Talks #1 - Becoming an iOS developer swiftly by Vedran Burojevic
PDF
Infinum Android Talks #17 - Testing your Android applications by Ivan Kust
PDF
Infinum Android Talks #17 - A quest for WebSockets by Zeljko Plesac
PDF
Infinum Android Talks #17 - Developing an Android library by Dino Kovac
PDF
Infinum Android Talks #17 - Intro by Ivan Kocijan
Infinum Android Talks #20 - Benefits of using Kotlin
Infinum iOS Talks #4 - Making our VIPER more reactive
Infinum Android Talks #13 - Using ViewDragHelper
Infinum Android Talks #14 - Log4j
Infinum Android Talks #9 - Making your app location-aware
Infinum Android Talks #14 - Gradle plugins
Infinum Android Talks #14 - Facebook for Android API
Infinum Android Talks #19 - Stop wasting time fixing bugs with TDD by Domagoj...
Infinum Android Talks #18 - Create fun lists by Ivan Marić
Infinum Android Talks #18 - In-app billing by Ivan Marić
Infinum Android Talks #18 - How to cache like a boss by Željko Plesac
Infinum iOS Talks #2 - VIPER for everybody by Damjan Vujaklija
Infinum iOS Talks #2 - Xamarin by Ivan Đikić
Infinum iOS Talks #1 - Swift under the hood: Method Dispatching by Vlaho Poluta
Infinum iOS Talks #1 - Swift done right by Ivan Dikic
Infinum iOS Talks #1 - Becoming an iOS developer swiftly by Vedran Burojevic
Infinum Android Talks #17 - Testing your Android applications by Ivan Kust
Infinum Android Talks #17 - A quest for WebSockets by Zeljko Plesac
Infinum Android Talks #17 - Developing an Android library by Dino Kovac
Infinum Android Talks #17 - Intro by Ivan Kocijan
Ad

Recently uploaded (20)

PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Big Data Technologies - Introduction.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Machine learning based COVID-19 study performance prediction
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Approach and Philosophy of On baking technology
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
KodekX | Application Modernization Development
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Cloud computing and distributed systems.
PDF
Encapsulation_ Review paper, used for researhc scholars
Network Security Unit 5.pdf for BCA BBA.
Agricultural_Statistics_at_a_Glance_2022_0.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Big Data Technologies - Introduction.pptx
The AUB Centre for AI in Media Proposal.docx
NewMind AI Weekly Chronicles - August'25 Week I
Machine learning based COVID-19 study performance prediction
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Approach and Philosophy of On baking technology
Chapter 3 Spatial Domain Image Processing.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Review of recent advances in non-invasive hemoglobin estimation
Building Integrated photovoltaic BIPV_UPV.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
KodekX | Application Modernization Development
Digital-Transformation-Roadmap-for-Companies.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Cloud computing and distributed systems.
Encapsulation_ Review paper, used for researhc scholars

Infinum iOS Talks #4 - Making your Swift networking code more awesome with Result