• Swift by Sundell is back!

    I never actually decided to stop writing Swift articles. It just sort of happened. In fact, for the past two years as this website has been very much dormant, I’ve lost count of the number of times that I’ve sat down at my desk with the intent to write and publish a new article, or…

    Read More

  • Modern URL construction in Swift

    These days, most applications need to work with URLs in some form. Perhaps they’re used to make network calls, to read and write files, or to perform various kinds of database operations. In Swift, URLs are by convention (and through the design of Apple’s frameworks) represented using the dedicated URL type, rather than just using…

    Read More

  • Using Swift’s defer keyword within async and throwing contexts

    Swift’s defer keyword allows us to delay the execution of a given block of code until the current scope is exited. While that might initially not seem that useful (after all, can’t we simply write that code at the end of the scope instead?), it turns out that when writing modern Swift code, we’re quite…

    Read More

  • Tips and tricks for when using SwiftUI’s ViewBuilder

    SwiftUI’s ViewBuilder type is a key part of the library’s overall API design, in that it’s what enables multiple view expressions to be declared within a given scope (such as a body property implementation, or a closure passed to containers such as HStack or VStack) without requiring any manual grouping or wrapping at each call…

    Read More

  • Decoding Swift types that require additional data

    Swift’s Codable API — which consists of the Encodable protocol for encoding, and Decodable for decoding — offers a powerful, built-in mechanism for converting native Swift types to and from a serialized format, such as JSON. Thanks to its integration with the Swift compiler, we often don’t have to do any additional work to enable…

    Read More

  • Deciding between ‘let’ and ‘var’ for Swift struct properties

    When declaring a Swift property, we use either the let or var keyword depending on whether we want our new property to be read-only once assigned through the enclosing type’s initializer, or whether we want to allow the property to be mutated and re-assigned multiple times. However, that’s not the only difference between using let…

    Read More

  • Podcast: “Responsive and smooth UIs”, with special guest Adam Bell

    Adam Bell returns to the podcast to discuss different techniques and approaches for optimizing UI code, and how to utilize tools like animations in order to build iOS apps that feel fast and responsive. Sponsors NordVPN: Get an exclusive discount on NordVPN’s excellent VPN service, by going to nordvpn.com/sundell. They even have a 30-day money-back…

    Read More

  • Combining opaque return types with primary associated types

    Ever since Swift was first introduced, it’s been very common to need to use type erasure when working with generic protocols — ones that either reference Self within their requirements, or make use of associated types. For example, in earlier versions of Swift, when using Apple’s Combine framework for reactive programming, every time we wanted…

    Read More

  • Podcast: “Swift concurrency in practice”, with special guest Ben Scheirman

    Ben Scheirman returns to the show to discuss how Swift’s built-in concurrency features, such as async/await and tasks, can be used in practice when building apps for Apple’s platforms. Sponsors Essential Developer: Join the iOS Architect Crash Course to accelerate your journey towards becoming a senior developer. It’s 100% free and held entirely online. NordVPN:…

    Read More

  • Podcast: “The evolution of Swift”, with special guest Nick Lockwood

    On this final episode of 2022, Nick Lockwood returns to the show to discuss the overall evolution of Swift and its ecosystem of tools and libraries. How has Swift changed since its original introduction in 2014, how does it compare to other modern programming languages, and how might the language continue to evolve in 2023…

    Read More