BLACK FRIDAY SALE: Save 50% on all my Swift books and bundles! >>

DAY 13

Protocols and extensions

Today you’re going to learn some truly Swifty functionality: protocols, extensions, and protocol extensions.

Protocol extensions allow us to do away with large, complex inheritance hierarchies, and replaces them with much smaller, simpler protocols that can be combined together. This really is the fulfillment of something Tony Hoare said many years ago: “inside every large program, there is a small program trying to get out.”

You’ll be using protocols from your very first SwiftUI project, and they’ll continue to be invaluable for your entire Swift coding career – it’s worth taking the time to get familiar with them.

Today you have four tutorials to follow, where you’ll meet protocols, extensions, and more. Once you’ve watched each video and optionally gone through the extra reading, there are short tests to help make sure you’ve understood what was taught.

Tip: This is one of the handful of days that will almost certainly take more than an hour to work through. I did warn you about this back in day 4, but that won’t make it feel any easier – there’s a lot to cover here! Remember, the optional reading is optional – if you understood a topic first time you’re welcome to skip it.

  1. How to create and use protocols
  2. How to use opaque return types
  3. How to create and use extensions
  4. How to create and use protocol extensions
  5. Summary: Protocols and extensions
  6. Checkpoint 8

Bonus: If you have even more time on your hands and want to explore this topic a little further, I created an extra tutorial just for you: How to get the most from protocol extensions. This is entirely optional, and definitely goes way beyond beginner Swift – you do not need to follow this tutorial in order to continue.

Have some questions about protocols?

Hit Send below to start a virtual conversation with me.

Share your progress!

If you use Twitter, the button below will prepare a tweet saying you completed today, along with a celebratory graphic, the URL to this page, and the challenge hashtag. Don't worry – it won't be sent until you confirm on Twitter!

Need help? Tweet me @twostraws!


Save 50% in my Black Friday sale.

SAVE 50% To celebrate Black Friday, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

Sponsor Hacking with Swift and reach the world's largest Swift community!

100 Days of SwiftUI

The 100 Days of SwiftUI is a free collection of videos, tutorials, tests, and more to help you learn SwiftUI faster. Click here to learn more, or watch the video below.

Back to 100 Days of SwiftUI

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.