Hacking with Swift News, tips, and tutorials from Hacking with Swift https://www.hackingwithswift.com/articles/rss (c)2020 Paul Hudson https://www.hackingwithswift.com/favicon-96x96.png Hacking with Swift https://www.hackingwithswift.com/articles/rss Year in review: 2020 https://www.hackingwithswift.com/articles/225/year-in-review-2020 https://www.hackingwithswift.com/articles/225/year-in-review-2020 A brief look back on another year of Hacking with Swift Fri, 01 Jan 2021 22:20:32 +0000 What the heck just happened? 😂

Many people – myself included – had big plans for the year. I wanted to work more on my open source software (Unwrap, Control Room, Sitrep, and more), I wanted to update a whole collection of books to be more focused on SwiftUI, I wanted to write new, shorter books to go alongside SwiftUI By Example, and more.

And then COVID-19 happened.

This meant my kids were home from school for many months, it meant I spent way too much time scrolling through depressing news rather than working, and honestly it meant a lot of the time I struggled to find the willpower to think about – never mind write about – anything.

So, this year turned out quite different from what I had anticipated, but there were still a few highlights…

Advance warning: This is a hugely self-indulgent article talking about what went well – and not so well – in my Hacking with Swift work this year. Hopefully you don’t find it too dull, but I only do it once a year!

Updates, rewrites, and more

This year I published a new, free book called Understanding Swift, which was entirely unlike all the other books I’ve written previously because I wanted each chapter to answer one question. The goal here was to focus firmly on why Swift is the way it is, because there are lots of code samples out there for any given topic but not a great deal of explanation of why features and functionality exists in the first place.

So, you’ll find chapters such as “What the heck are closures and why does Swift love them so much?”, “When should you write throwing functions?”, “How do Swift’s memberwise initializers work?”, and more – all questions that I was commonly asked by folks who were completing the 100 Days of SwiftUI.

I also published [Swift on Sundays Volume 1](h...

8 Common SwiftUI Mistakes - and how to fix them https://www.hackingwithswift.com/articles/224/common-swiftui-mistakes-and-how-to-fix-them https://www.hackingwithswift.com/articles/224/common-swiftui-mistakes-and-how-to-fix-them Write less code and get more done Fri, 09 Oct 2020 13:29:31 +0000 SwiftUI is a big and complex framework, and although it’s great fun to work with there’s also a lot of scope for making mistakes. In this article I’m going to walk through eight common mistakes SwiftUI learners make, and how to fix them.

Some of these mistakes are simple misunderstandings, and with SwiftUI being so big these are easy to make. Others are about getting a deeper understanding of how SwiftUI works, and still others are more a sign of legacy thinking – sometimes you spend a lot of time writing views and modifiers and don’t take the time to simplify the end result.

Anyway, I’m not going to keep you in suspense about what these eight mistakes are, so here’s a brief summary before we dive into them:

  1. Adding views and modifiers where they aren’t needed
  2. Using @ObservedObject when they mean @StateObject
  3. Putting modifiers in the wrong order
  4. Attaching property observers to property wrappers
  5. Stroking shapes when they mean to stroke the border
  6. Using alerts and sheets with optionals
  7. Trying to get “behind” their SwiftUI view
  8. Creating dynamic views using invalid ranges

If you prefer to watch a video instead, I've got you covered!

Still here? Okay, let’s get into it…

1. Adding views and modifiers where they aren’t needed

Let’s start with one of the most common, which is writing more SwiftUI code than you actually need. This is common partly because it’s often we write a lot of code as we’re figuring out a problem, but it’s easy to forget to clean up that code afterwards. It’s also sometimes a matter of slipping back into old habits, particular if you’ve come from UIKit or other user interface frameworks.

As a starting example, how might you fill the screen with a red rectangle? You might write this:


And honestly that works great – it gets the exact result you want. But half that code isn’t needed, because you can instead just s...

Hacking with Swift Live 2020 raises $38,000 for charity https://www.hackingwithswift.com/articles/223/hacking-with-swift-live-2020-raises-38000-for-charity https://www.hackingwithswift.com/articles/223/hacking-with-swift-live-2020-raises-38000-for-charity Make apps, make friends, make a difference Thu, 16 Jul 2020 16:55:11 +0000 Hacking with Swift Live 2020 just finished, delivering four days of packed tutorials and workshops walking through all the major new features for SwiftUI, UIKit, and more. Even better, because all our profits go to charity we were able to donate $38,000 to an incredible cause – folks made friends, learned lots of new Swift skills, and made a difference to the wider world.

I’m hugely grateful to everyone who bought a ticket to the event, and the feedback so far has been really positive. Over four days we really got to know each other even though it was a remote event, and it’s amazing to see folks leaving with new friends. Thank you so much for coming!

I’m also really grateful to our two sponsors: Bitrise came back for a second year as platinum sponsor, and several members of their team came along to the event. Instabug also joined as silver sponsor for the first time, and it was great to have them on board.

Both those companies could easily have used that money to show adverts on Google, Twitter, or other services, but they instead chose to make a significant charitable donation in order to support a community conference like this one. Thank you so much!

Just like last year, we donated all our profits to Special Effect, who do remarkable work to help bring joy, laughter, creativity, and confidence into the lives of disabled children and adults. With the pandemic still raging many charities are having a hard time raising funds, so we’re glad to play a part in helping continue their awesome work.

This event wouldn’t have been possible without the help of the organizing team: Chris Rivers, Daniel Leivers, Ian Lockett, and my wife Ildiko. We all work really hard to bring this event to you and don’t get paid a penny – we send everything we can to charity.

So, ...

WWDC20: Wrap up and recommended talks https://www.hackingwithswift.com/articles/222/wwdc20-wrap-up-and-recommended-talks https://www.hackingwithswift.com/articles/222/wwdc20-wrap-up-and-recommended-talks Packed Sessions, hands-on labs, and a look forward to next year Sun, 28 Jun 2020 14:30:24 +0000 WWDC20 was a packed event as always, with some incredible steps forward for macOS, SwiftUI, and more. Was it better than the regular event? Yes. Will it go back to how it was before? That’s harder to say.

In this article I’ll go over how I thought the sessions and labs compared to an in-person WWDC event, pick out my favorite community events, cover the talks I enjoyed the most and the talks I think you should watch if you're short on time, and also look forward to what might happen next year.

Full stream ahead from Apple Park

Even from the very first minutes of the keynote it was clear these WWDC presentations were going to be like no other. First, the video quality was – predictably – stunning, and on a 4K TV it felt like you were in the room with Tim, Craig, and the others. Second, Apple Park was a key cast member: they jumped around from the Steve Jobs Theater to the health studio, to the “secret underwater lab” and it felt amazing.

A long camera shot that seems to take us from Steve Jobs Theater to a secret underwater lab.

None of this would have been possible in a regular WWDC20. You’d never get that close to the various senior Apple folks, and although I have a fondness for the McEnery Center it’s never going to come close to Apple Park.

Throughout the week, the video production naturally became more practical and less glitzy as the topics became hands on, but the actual production quality was still very high. I can’t imagine how much time it must have taken to make each video, because each one was clearly stitched together from many takes.

The remote format allows several things:

  1. Each video was only as long as it needed to be. Most previous WWDC talks aimed to be about 40 minutes so they could keep a fixed structure at the venue, but at WWDC20 I watched many that were under 15 minutes. These weren’t just “easy talks” either – [Advances in diffable data sources](https://developer.apple.com/videos/play/wwdc20...
What’s new in SwiftUI for iOS 14 https://www.hackingwithswift.com/articles/221/whats-new-in-swiftui-for-ios-14 https://www.hackingwithswift.com/articles/221/whats-new-in-swiftui-for-ios-14 Text views, grids, color pickers, and more! Mon, 22 Jun 2020 22:27:42 +0000 SwiftUI was inevitably going to see big changes this year, and I’m really excited to experiment with them all – text views, color pickers, progress views, and even limited support for grids have all landed. Alongside massive improvements to Swift itself (see What's new in Swift 5.3 for more on that), this is a huge leap forward for SwiftUI – we can now make a much wider range of apps.

Please keep in mind that these changes are very new – I'm pushing it as hard as I can, experimenting, refining, sharing, and learning all at the same time. If you have any feedback, please tweet me @twostraws.

You can watch the video below, or scroll down for links to articles.

The big stuff

More welcome improvements

Introducing Hacking with Swift+ https://www.hackingwithswift.com/articles/220/introducing-hacking-with-swift-plus https://www.hackingwithswift.com/articles/220/introducing-hacking-with-swift-plus A new subscription service to help deepen your knowledge of Swift Thu, 04 Jun 2020 14:53:44 +0000 Every day 40,000 people visit Hacking with Swift to learn Swift, solve a problem with their code, or get advice for their iOS career, reading 5,000,000 pages over the course of an average month.

Serving the community I’m part of has always been important to me, which is why I try to give away as much free content as I can – free videos, free tutorials, free example code, free interview tests, and more, all to help people achieve their goals with Swift.

I want to continue this work as long as I can, and help as many people as I can, which means I need a solution to financially support my work for the long term.

Well, that solution is finally here: it’s called Hacking with Swift+, and it’s my first ever subscription option for Swift content. The first articles are already published, with each one having 4K Ultra HD video attached, and there are many more to come.

All articles posted there will come with video, so folks can read or watch depending on what they prefer, and three courses already have their first videos published: Advanced Swift, Custom SwiftUI Components, and High-Performance Apps – many more will come soon.

I still plan to release as much free content as I can, but I’m hoping this subscription option will create a firm foundation for Hacking with Swift for years to come. I’m working on so many exciting things right now, and I can’t wait to share them!

To find out more or subscribe to Hacking with Swift+, click here.

New book: Understanding Swift https://www.hackingwithswift.com/articles/219/new-book-understanding-swift https://www.hackingwithswift.com/articles/219/new-book-understanding-swift Answers common beginner questions and more Fri, 29 May 2020 09:03:27 +0000 I've just published a new book called Understanding Swift, complementing my 100 Days of Swift and 100 Days of SwiftUI courses by answering the most common questions folks have. Everything I have released for the last 20 months has been available free, and this new book is also free right here: Understanding Swift

This book is different from my others that show you how to build stuff with Swift, because this one is trying to answer many of the "why" questions learners have – why are tuples different from structs? Why do copies of a class share data? Why would you want a failable initializer?

You might look at some of the questions and think they are easy, but every one of them was drawn from questions I've been asked by folks completing the 100 Days of Swift/SwiftUI – this book tries to bring them into one place so folks hit fewer problems and feel more encouraged.

If you'd prefer a download edition of Understanding Swift, you can buy it here. But I want to get this to everyone who needs it, so I'm retroactively adding it to my Swift Power Pack

Last December I launched a Patreon so folks could help support my work, and it's helped keep things afloat. So, Understanding Swift is dedicated to everyone who supports me on Patreon – thanks, folks!

You can find out more about my Patreon here.

PS: If you're following the 100 Days of Swift/SwiftUI, I have added links to Understanding Swift directly to each day so you have optional extra reading if you want it.

What’s new in Swift 5.3? https://www.hackingwithswift.com/articles/218/whats-new-in-swift-5-3 https://www.hackingwithswift.com/articles/218/whats-new-in-swift-5-3 Multiple trailing closures, massive package manager improvements, and more. Fri, 15 May 2020 13:10:35 +0000 Swift 5.3 brings with it another raft of improvements for Swift, including some powerful new features such as multi-pattern catch clauses and multiple trailing closures, plus some important changes for Swift Package Manager.

In this article I’m going to walk through each of the major changes, while providing hands-on code samples so you can try them yourself. I encourage you to follow the links through to the Swift Evolution proposals for more information, and if you missed my earlier what's new in Swift 5.2 article then check that out too.

Multi-pattern catch clauses

SE-0276 introduced the ability to catch multiple error cases inside a single catch block, which allows us to remove some duplication in our error handling.

For example, we might have some code that defines two enum cases for an error:

enum TemperatureError: Error {
    case tooCold, tooHot

When reading the temperature of something, we can either throw one of those errors, or send back “OK”:

func getReactorTemperature() -> Int {

func checkReactorOperational() throws -> String {
    let temp = getReactorTemperature()

    if temp < 10 {
        throw TemperatureError.tooCold
    } else if temp > 90 {
        throw TemperatureError.tooHot
    } else {
        return "OK"

When it comes to catching errors thrown there, SE-0276 lets us handle both tooHot and tooCold in the same way by separating them with a comma:

do {
    let result = try checkReactorOperational()
    print("Result: \(result)")
} catch TemperatureError.tooHot, TemperatureError.tooCold {
    print("Shut down the reactor!")
} catch {
    print("An unknown error occurred.")

You can handle as many error cases as you want, and you can even bind values from ...

The Complete Guide to Layout in SwiftUI https://www.hackingwithswift.com/articles/217/complete-guide-to-layout-in-swiftui https://www.hackingwithswift.com/articles/217/complete-guide-to-layout-in-swiftui HStack, VStack, ZStack, Spacer, GeometryReader, and more Fri, 01 May 2020 15:48:40 +0000 SwiftUI gives us a huge range of tools to control layouts, from the core tools of HStack, VStack, and ZStack, through to more advanced views such as GeometryReader and Group, plus modifiers such as layoutPriority().

I’ve published a lot of articles and videos about those and more, but this article brings them all together in one place for easy reference.

If I missed something off this list, let me know on Twitter.

How layout works in SwiftUI

Before we get into the details of specific layout techniques, you should start with my video “How layout works in SwiftUI” – it outlines exactly how things fit together to give us lots of power and flexibility:

If you’d rather read the article instead, you can find it here: How layout works in SwiftUI.

The basics of layout stacks, frames, and ForEach

A handful of view types lie at the center of all our SwiftUI layouts, and if you understand them then you’re already half way to making great UI.

Start with these four to get a firm understanding of the basics:

Of course, you’re not restricted to working in one dimension – you can create your own stacks if you want....

The Complete Guide to NavigationView in SwiftUI https://www.hackingwithswift.com/articles/216/complete-guide-to-navigationview-in-swiftui https://www.hackingwithswift.com/articles/216/complete-guide-to-navigationview-in-swiftui Programmatic navigation, customization, and more Wed, 29 Apr 2020 16:11:35 +0000 NavigationView is one of the most important components of a SwiftUI app, allowing us to push and pop screens with ease, presenting information in a clear, hierarchical way for users. In this article I want to demonstrate the full range of ways you can use NavigationView in your apps, including simple things like setting a title and adding buttons, but also programmatic navigation, creating split views, and even handling other Apple platforms such as macOS and watchOS.



Getting a basic NavigationView with a title

To get started with NavigationView you should wrap one around whatever you’re trying to display, like this:

struct ContentView: View {
    var body: some View {
        NavigationView {
            Text("Hello, World!")

For simpler layouts navigation views should be the top-level thing in your view, but if you’re using them inside a TabView then the navigation view should be inside the tab view.

When learning SwiftUI, one thing that folks find confusing is how we attach titles to a navigation view:

NavigationView {
    Text("Hello, World!")

Notice how the navigationBarTitle() modifier belongs to the text view, not to the navigation view? That’s intentional, and is the correct way to add a title here.

You see, navigation views let us display new screens of content by sliding them in from the right edge. Each screen can have its own title, and it’s the job of SwiftUI to make sure that title is shown in the navigation view at all times – you’ll see the old title animate away, while the new title animates in.

Now think about this: if we had attached the title directly to the navigation view, w...

Spot the Swifty https://www.hackingwithswift.com/articles/215/spot-the-swifty https://www.hackingwithswift.com/articles/215/spot-the-swifty Explore a cartoon world without social distancing. Wed, 01 Apr 2020 08:00:04 +0000 It’s April Fools day, and with the world as it is right now I figured folks in our community could use a little distraction – even if only for 10 minutes.

So, I’ve spent the last six weeks working with the talented illustrator Gus Morais to produce a massive picture that’s packed with fun details for you to discover. Plus, there are 30 well-known folks from the Swift community scattered through the picture – can you find them all?

The original picture itself is huge, weighing in at 5374x3508, but once you factor in a key helping you identify everyone you should be looking for, the finished result is an eye-watering 12850x5700 pixels in size.

So, you should open one of the pictures below in a new window, then zoom to see all the details – along with the 30 people there’s lots more to discover! Some people are harder to discover than others, and honestly I think you’ll struggle to find all 30. Prove me wrong, if you dare!

Regardless, I hope this picture provides you with a little fun today. Thanks for being a part of our incredible community ❤️

Remember: these folks can stand close together because they are cartoons, but you’re not – stay safe, and practice social distancing!

I’ve provided two versions of the picture: the original, and the original plus a key. If you think you really know the Swift community then try the first one, but if you need a little help check out the second…

Spot the Swifty

Make sure and click the pictures to see the full-sized version!

Spot the Swifty with Key

8 essential apps for iOS developers https://www.hackingwithswift.com/articles/214/essential-apps-for-ios-developers https://www.hackingwithswift.com/articles/214/essential-apps-for-ios-developers Make iOS and macOS do more work for you Mon, 30 Mar 2020 15:07:21 +0000 App developers use apps just as much as anyone else, but as well as things like Overcast, PCalc, and Reddit, we also use apps specifically designed to make development easier – apps aimed at developers.

In this article I want to pick out a handful I can personally recommend. None of these were provided free; I bought them all and can recommend them all from experience. If you make a development-focused app that I missed off, send me a tweet with a link and I’ll check it out!

Adaptivity A

Apple gives us many sizes, colors, icons, and more to work with, and sometimes it can be hard to remember which is which – should you use readable content margins here, to layout margins? Which Dynamic Type font is the correct choice for a particular layout? How about when all those are used inside a local notification UI?

Adaptivity by Geoff Hackworth is an app that aims to answer all those questions and more, allowing you to see visually how various layout guides interact, how all the Dynamic Type font families look (even with custom font support), how the safe area adjusts as navigation views and toolbars are shown and hidden, and practically everything else you could want from your layouts.

The app itself is remarkably simple: you see various common layouts such as plain view controllers, table view controllers, split view controllers, and more, each overlaid with various colored lines showing you the available space using differing measurement guides. But the app then goes on to show you more complex scenarios: what happens if you show this view controller in a context menu, or as part of a local notification? It even has a home screen quick action showing you how the layout adapts inside an action extension!

It seems ridiculous that this app costs just $3.99, because if you use it just once to figure out a layout problem it has earned its money back immediately. Even better, it’s a universal purchase that works acr...

How to build neumorphic designs with SwiftUI https://www.hackingwithswift.com/articles/213/how-to-build-neumorphic-designs-with-swiftui https://www.hackingwithswift.com/articles/213/how-to-build-neumorphic-designs-with-swiftui Try out a new design trend and learn something new Wed, 26 Feb 2020 14:35:41 +0000 Neumorphic design is easily the most interesting design trend of recent months, although to be fair Apple did use it as their design motif way back in WWDC18. In this article we’re going to look at how you can build neumorphic designs using SwiftUI, why you might want to, and – most importantly – how we can modify those designs to be more accessible.

Important: Neumorphism – sometimes called neomorphism – has serious implications for accessibility, so although it’s tempting to read the first part of this article then skip the rest, I encourage you to stick around and learn the downsides as well as the upsides so you get the full picture.



The basics of neumorphism

Before we get into the code, I just want to briefly touch on the two core principles of this design trend, because it will be relevant as we progress:

  1. It uses highlights and shadows to define the shapes of objects on the screen.
  2. Contrast is generally reduced; full white or black aren’t used, which is what allows the highlights and shadows to stand out.

The end result is an “extruded plastic” look – a user interface design that certainly looks fresh and interesting without being harsh on your eyes. I can’t repeat enough that reducing contrast and relying on shadows for shapes has serious impacts on accessibility, and we’ll be coming back to this later.

However, I still think it’s worth taking the time to explore neumorphism in SwiftUI – even if you don’t use it in your own apps, it’s a bit like a coding kata that will help hone your skills.

OK, enough waffle – let’s look at some code.

Building a neumorphic card

The simplest starting point is to build a neumorphic card: a rounded rectangle that will contain some inf...

What’s new in Swift 5.2 https://www.hackingwithswift.com/articles/212/whats-new-in-swift-5-2 https://www.hackingwithswift.com/articles/212/whats-new-in-swift-5-2 Key path expressions as functions, callAsFunction, and more Wed, 05 Feb 2020 23:29:22 +0000 Swift 5.2 arrived with Xcode 11.4, and includes a handful of language changes alongside reductions in code size and memory usage, plus a new diagnostic architecture that will help you understand and resolve errors faster.

In this article I'm going to walk through what's changed with some hands-on examples so you can see for yourself how things have evolved. I encourage you to follow the links through to the Swift Evolution proposals for more information, and if you missed my earlier what's new in Swift 5.1 article then check that out too.

Key Path Expressions as Functions

SE-0249 introduced a marvelous shortcut that allows us to use keypaths in a handful of specific circumstances.

The Evolution proposal describes this as being able to use “\Root.value wherever functions of (Root) -> Value are allowed”, but what it means is that if previously you sent a Car into a method and got back its license plate, you can now use Car.licensePlate instead.

This is best understood as an example, so here’s a User type that defines four properties:

struct User {
    let name: String
    let age: Int
    let bestFriend: String?

    var canVote: Bool {
        age >= 18

We could create some instance of that struct and put them into an array, like this:

let eric = User(name: "Eric Effiong", age: 18, bestFriend: "Otis Milburn")
let maeve = User(name: "Maeve Wiley", age: 19, bestFriend: nil)
let otis = User(name: "Otis Milburn", age: 17, bestFriend: "Eric Effiong")
let users = [eric, maeve, otis]

Now for the important part: if you want to get an array of all the users names, you can do so by using a key path like this:

let userNames = users....
Apple announces SwiftCrypto, an open-source implementation of CryptoKit https://www.hackingwithswift.com/articles/211/apple-announces-swiftcrypto-an-open-source-implementation-of-cryptokit https://www.hackingwithswift.com/articles/211/apple-announces-swiftcrypto-an-open-source-implementation-of-cryptokit Get Swifty cryptography everywhere Mon, 03 Feb 2020 17:35:39 +0000 Update: Cory Benfield from Apple has confirmed that on Apple's platforms SwiftCrypto is limited to those that support CryptoKit, and can't act as a polyfill for older releases such as iOS 11/iOS 12 and macOS 10.14. However, there's hope that might change – Cory added "we’d be happy to discuss that use-case with the community." In theory that could mean we get SwiftCrypto support for iOS 12 and earlier, which would be awesome!

Apple today released SwiftCrypto, an open-source implementation of the CryptoKit framework that shipped in iOS 13 and macOS Catalina, allowing us to use the same APIs for encryption and hashing on Linux.

The release of SwiftCrypto is a big step forward for server-side Swift, because although we’ve had open-source Swift cryptography libraries in the past this is the first one officially supported by Apple. Even better, Apple states that the “vast majority of the SwiftCrypto code is intended to remain in lockstep with the current version of Apple CryptoKit,” which means it’s easy for developers to share code between Apple’s own platforms and Linux.

What’s particularly awesome about SwiftCrypto is that if you use it on Apple platforms it effectively becomes transparent – it just passes your calls directly on to CryptoKit. This means you can write your code once using import Crypto, then share it everywhere. As Apple describes it, this means SwiftCrypto “delegates all work to the core implementation of CryptoKit, as though SwiftCrypto was not even there.”

The only exception here is that SwiftCrypto doesn’t provide support for using Apple’s Secure Enclave hardware, which is incorporated into devices such as iPhones, Apple Watch, and modern Macs. As the Secure Enclave is only available on Apple hardware, this omission is unlikely to prove problematic.

Try it yourself

SwiftCrypto is available today, so why not give it a t...

How to fix slow List updates in SwiftUI https://www.hackingwithswift.com/articles/210/how-to-fix-slow-list-updates-in-swiftui https://www.hackingwithswift.com/articles/210/how-to-fix-slow-list-updates-in-swiftui Make it faster with this one weird trick! Fri, 10 Jan 2020 14:35:21 +0000 If you have a SwiftUI list with lots of rows, you might find it's really slow to update when you sort or filter those rows – code that should run instantly might take one or two seconds, or if you have lots of items one or two minutes.

I'm going to show you what code causes the problem, then show you the one line of SwiftUI code that fixes it, and finally the most important part: explain why the problem occurs so you aren't just adding code without understanding it.

Let's go to Xcode…


Prefer video? The screencast below contains everything in this tutorial and more – subscribe to my YouTube channel for more like this.


Our problem code

Here's a concise piece of SwiftUI code that demonstrates our problem:

struct ContentView: View {
    @State var items = Array(1...600)

    var body: some View {
        VStack {
            Button("Shuffle") {

            List(items, id: \.self) {
                Text("Item \($0)")

There I have a view that has one property, which is an array of 600 integers from 1 to 600.

Inside the body there's a VStack with a Button that shuffles the items every time it's pressed, and a List that shows all the items. Shuffling the array is how we're simulating you changing the items, because it forces the list to update its rows.

If you run that code in the simulator you'll see the button and list of items, and if you press the button you'll see nothing happens – at least at first. If we wait a little longer… boom, the list updates. And if you press the button again, the same thing h...

Year in review: 2019 https://www.hackingwithswift.com/articles/209/year-in-review-2019 https://www.hackingwithswift.com/articles/209/year-in-review-2019 A brief look back on another year of Hacking with Swift Sun, 29 Dec 2019 17:38:10 +0000 2019 was my busiest year to date: hundreds of new articles, new videos, a conference, an app, a mentoring program, and a whole lot of charity work – I really feel I made the most of my time and position.

Howeer, I usually spend so much time doing the work that I don’t have much time left over to reflect on it all. So, once again I’ve written this Year in Review post to help summarize what I worked on, what results that work had, and what I’m planning for 2020.

As a reminder, this is my full-time job – don’t look at the below and imagine I’m some sort of super-productive genius, because the simple truth is that this is all I do. I don’t have meetings to attend, Jira backlogs to dig through, pull requests to review, and so on; I’m lucky enough that my entire job is exploring Swift development and sharing what I learned with others.

OK, let’s see what happened in 2019…

Publishing my brain

Have you ever been in the middle of a particular project, but had your brain so fizzing with ideas for a side project that you’ve had to stop what you were doing and work on that other thing for a while?

Me too. And I get it for writing a lot – I’m working with Swift all the time, and my brain leaps around between projects, APIs, and even platforms as I’m trying things that have my brain excited and as connections jump out at me. These things keep me up at night sometimes: if I try to sleep without writing them down my brain just stays in gear, developing it more and more. The only solution I have is to write down my ideas, save my code somewhere safe, then come back to it as soon as possible.

This year I made it a priority to get those notes out of my drafts folder, polish them up, and get them out there into the world. The result was a remarkable collection of tutorials that have really helped take the site to the next level:

  • I started the year with Xcode in 20 Seconds, which made 40 daily videos teaching interesting features of Xcode in 20 seconds or less. The...
Save 50% in the Hacking with Swift Black Friday sale https://www.hackingwithswift.com/articles/208/save-50-in-the-hacking-with-swift-black-friday-sale https://www.hackingwithswift.com/articles/208/save-50-in-the-hacking-with-swift-black-friday-sale All books and bundles are half price! Mon, 25 Nov 2019 10:54:49 +0000 If you want to take your Swift learning further without breaking the bank, you’ll be pleased to know that all Hacking with Swift books and bundles are half price for Black Friday 2019 – there has never been a better time to stock up on fantastic Swift tutorials!

New this year: The sale includes my latest bundle, the Swift Plus Pack, and you can even save 50% on the pre-order for my latest book: Swift on Sundays Volume One.

50% off all bundles

I try to keep the prices of my books as low as possible, but if you buy the bundle you get an extra saving – and if you buy a bundle during this Black Friday sale you get a triple saving!

50% off all books

All my books are half price for this sale, and still come with a lifetime Swift update policy that ensure your learning never goes out of date.

Nominations open for the 2019 Swift Community Awards https://www.hackingwithswift.com/articles/207/nominations-open-for-the-2019-swift-community-awards https://www.hackingwithswift.com/articles/207/nominations-open-for-the-2019-swift-community-awards Nominate the people and projects that help you the most Tue, 19 Nov 2019 22:19:16 +0000 The Swift Community Awards are back for their third year, helping celebrate our amazing community and recognize the hard work of people and projects that help make Swift great.

Right now you can post nominations across 10 categories:

  • Best newsletter
  • Best conference
  • Best podcast
  • Best design tool
  • Best third-party service
  • Best developer tool
  • Best open-source project
  • Most inspiring indie app
  • Most inspiring presentation
  • Rising star

All categories are optional, so you can vote only in the ones you want to.

Click here to find out more about the categories and add your nominations. Nominations close on November 26th, with the shortlist open for final voting on November 28th.

The Best Swift and iOS conferences in 2020 https://www.hackingwithswift.com/articles/206/the-best-swift-and-ios-conferences-in-2020 https://www.hackingwithswift.com/articles/206/the-best-swift-and-ios-conferences-in-2020 Learn more Swift and meet new friends at the same time. Wed, 13 Nov 2019 14:39:45 +0000 Our community has a huge number of awesome conferences around the world, so regardless of where you live there's usually a conference nearby. Of course, there are also many conferences far away too, so if you want to combine learning Swift with some sightseeing it's a double win!

I've had the privilege of attending so many events around the world, so each year I draw up a list of conferences I can personally vouch for – events where I know folks are welcomed regardless of their background, where you can expect high-quality speakers, and where there are lots of good opportunities for networking and making friends.

Below is my list for 2020, and I have included dates below where they have been announced. Where 2020 editions haven’t been announced yet, I’ve included last year’s month with a question mark.

iOS Conf SG

January 15th-18th, Singapore (Link)

This event always starts our year off with a bang, and is the largest iOS conference in south-east Asia. This year it now runs across two workshop days plus two days of sessions, and the speaker line-up already includes Dave Verwer, Ellen Shapiro, Meng To, and more. Last year I was really impressed by the huge range of attendees – many were from Singapore and Malaysia, of course, but also from Indonesia, Japan, Australia, and beyond; it's a massive mix.


February 3rd, Paris, France (Link)

dotSwift has a long-standing tradition of events in astonishing venues, tight time slots for speakers, and a complete ban on electronics in the audience. The result is something quite remarkable: given just 18 minutes to speak everyone on stage has honed their talk to the best it can be, so rather than chatting on Slack the audience is fully focused on learning. It sounds odd at first, but trust me: it works.


February 20th-21st, Cluj Napoca, Romania (Link)

Returning for the seventh year in a row, MobOS is the largest and...