CodeCompletion.io

Episode 39: Breakpoint Breadcrumbs

Welcome to Code Completion, Episode 39! We are a group of iOS developers and educators hoping to share what we love most about development, Apple technology, and completing your code!

Follow us @CodeCompletion on Twitter to hear about our upcoming livestreams, videos, and other content.

Be sure to also sign up to our monthly newsletter, where we will recap the topics we discussed, reveal the answers to #CompleteTheCode, and share even more things we learned in between episodes.

You are what makes this show possible, so please be sure to share this with your friends and family who are also interested in any part of the app development process.

โญ๏ธ This Week's Topics

  • Debugging Discussion
  • View Debugging
    • Reveal: https://revealapp.com
  • os_signpost and logging

๐Ÿšง #CompleteTheCode

This week's #CompleteTheCode:

Assuming these steps need to be performed in the order they are presented, how would you improve this code?
1
2
3
4
5
6
7
// Assuming these steps need to be performed in the order
// they are presented, how would you improve this code?
let results = array
    .map { $0.path }
    .filter { $0.hasPrefix("/Documents") }
    .compactMap { $0.components(separatedBy: "/").last }
    .prefix(maxEntries)

Be sure to tweet us with hashtag #CompleteTheCode if you know the answer!

โš ๏ธ Compiler Error

This week's theme: Error Handling!

  1. NSError supports built-in error recovery through the use of a recovery attempter, allowing the origin of the error a chance to handle things like retries when delivered to an NSAlert.
  1. A custom Swift Error type can provide localized description information by conforming to LocalizedError and overriding localizedDescription.
  1. Although it isnโ€™t possible to specify the type of Error thrown from a method in Swift, it is possible to restrict the error type when it is delivered within a Result.
  1. It is possible to omit localized descriptions and failure reasons when creating an NSError while still making this information available to consumers of the error by creating a userInfo provider for the error domain.

๐ŸŽ Sponsor

This week's episode of Code Completion is brought to you by Weekly Swift Exercises! Subscribe to the Mailinglist today to subscribe!

๐Ÿ“บ Watch the Stream