Michael Williams

Using Result with Network Requests

Michael Williams | Apr 22, 2019

How do I use Result type in networking code?

When working with networking code, most APIs send back optional types (usually an error and one or two other types such as a response and data), but there is no compile-time guarantee that all of these will not be nil.

In today’s screencast I will be showing you how to use Swift 5’s new Result type in our networking APIs to make them cleaner and easier to reason about.

After this screencast, you'll be able to implement the Result type in asynchronous/networking APIs instead of optionals.


  • Xcode 10.2+ installed
  • Basic knowledge of completion handlers
  • Knowledge of how to implement URLSession

For the More Curious...

Result | Apple Documentation
BNR Guide to iOS
BNR Guide to Swift
iOS & Swift Courses

Subscribers Only

Transcripts are for subscribers. Create an account today to access our collection of screencasts, skill packs, and more.

Subscribers Only

Project files are only available for subscribers. Create an account today to access our collection of screencasts, skill packs, and more.

Need Help?

If you get stuck, try starting a discussion with Big Nerd Ranch experts in the community tab.

Related Screencasts

Explore other screencasts related to this topic.

IBInspectable and IBDesignable

5 minutes

In this screencast, you will learn how to use @IBDesignable and @IBInspectable to configure your custom views using the storyboard.

Setting Up StackViews Inside ScrollViews

4 minutes

In this screencast, we’ll show you how to set up a StackView inside a ScrollView, this will help you to create views that have to show list of related data without use table views or collection views.

Creating an App Widget

10 minutes

Mobile devices are all about convenience. Users want to get the information they need from your app quickly and easily. Apple has added the Today view with widgets for just this reason. Widgets provide app users with a way of quickly accessing important features and content of your apps without having to open each app one by one. In this screencast, we'll go over how to create a widget for your app.

Protocol Oriented Dependency Injection

8 minutes

Tight coupling between view controllers in your application can lead to difficult maintenance as you add and remove features. This video will explore how using Protocols can make our Dependency Injection more loosely coupled. This improves the flexibility of the code and makes our application easier to change.

Finding and Fixing Memory Issues

7 minutes

Incorrectly managing memory in our applications can result in hard to find bugs and possible crashes. In this video, we will explore the Memory Graph debugging tool in Xcode and how you can use it to find and fix strong reference cycles in closures.

Using Container Views to Manage Complex Layouts

7 minutes

When you have a complex view controller view, sometimes it is helpful to break up the view into manageable chunks. In this video we will show how you can use container views to simplify the construction of certain layouts. After this video you will know when and how to use these container views in your applications.