I recently released an app written 100% in SwiftUI and in doing so, uncovered some patterns that are difficult to express. In this post, I am going to explain how to set initial state in SwiftUI. It’s trickier than you’d expect.
There are three types of local state in SwiftUI:
There’s also external state with environment variables and observables, but I’m going to ignore these in this post for brevity.
If you have some local state…
This is part 2 of a series in writing an elegant and extensible network stack in Swift. You can read part 1 here.
Writing your own networking stack is easy! One of the main advantages of owning your stack is that it’s simple to add additional features. You can pick and choose what you add depending on the specific needs of your application. You don’t need your stack to support every feature anyone could think of, but if you own your code, you can easily add in features when appropriate.
In this post, I’ll show a few examples of extending…
Apple constantly updates their networking APIs to make them easier to use. However, I find that a lot of people still are hesitant to write their own networking layer and choose to rely on common open source solutions.
Writing your own networking stack has several benefits. To name just a few:
Offline mode is no longer just an extra feature you could choose to add to your app — it’s something many users expect. I’ve often seen developers force their favorite offline solution on a problem that could be solved in a better way.
There are many different ways of making an app work offline, each with advantages and drawbacks. There’s no magic bullet that will work every time, so it’s up to you to carefully weigh your options. Sometimes, the best solution may be a combination of several different technologies!
The main solutions available to make the app work offline…
In the card game ‘Bullshit’ (aka ‘Cheat’ or ‘BS’), players can lie about their cards for an advantage. Calling someone’s bluff is risky — if you’re wrong, then you’re punished. Players aren’t incentivised to call bullshit on someone else because it incurs too much personal risk.
I wanted to dive into the game theory of ‘Bullshit’ so I wrote a short application to simulate the game. I coded several different strategies, played them against each other thousands of times, and worked out the win rate of each strategy.
You can try playing against the best strategies yourself here. It’s tough…
Backend engineers know exactly what’s going on with their services. They know their QPS, memory footprint, error rate, and CPU utilization in real time. They even get paged automatically if there’s a critical error so they can respond quickly. Unfortunately, iOS engineers usually only have crash reporting and maybe some product metrics. Usually, we learn about bugs when a user reports it, or worse, when a user posts a bad review. We can do better.
This post is about one of my favorite brainteasers. I love it for two reasons:
The puzzle has a logical solution, but wanted to test whether actual humans would come to that solution by simulating the puzzle in real life with seven participants. But first, if you haven’t heard it before, you should spend some time to solve it yourself.
Seven pirates have 100 gold coins to split amongst themselves. They have chosen an interesting way of splitting the pot.
Likely, your app’s onboarding experience isn’t very good. This isn’t because your product isn’t well designed or easy to learn; it’s because building successful onboarding experiences is just hard.
A couple of months ago, my chess puzzle app was struggling to retain new users. I loved the app, and many of my users did too, but, most people who downloaded the app wouldn’t use it more than once. So, I decided to build an onboarding experience for all the lost users.
HORSE may seem like a simple backyard game, but, surprisingly, there is a strategy which improves your chance of winning — and it probably isn’t what you’d expect.
HORSE is a popular basketball game where players take turns attempting the same shot. With two players, the game works like this:
At Superhuman, we’re building the fastest email experience in the world.
This post describes several techniques to debug closed source libraries such as UIKit.
As we’ve pushed iOS to its limits, we’ve found some inscrutable runtime bugs. In order to solve these, we’ve had to dive into the deepest internals of UIKit.
Since UIKit is closed source, we can’t place breakpoints or view the code. However, as we’ll see, nothing in Objective-C is really private.
In this post, we’ll cover:
Most of these examples are…