Concurrency
Concurrency lets our apps do several things at once without making people wait, but it also makes our code harder to reason about. These posts look at doing it safely.
Sneaky Date Formatters Exposing More Than You Think
DateFormatters are expensive to build, so we cache them. DateFormatters are useful, so we share that cache. DateFormatters are mutable, so we end up with hard-to-reproduce bugs. Here, we look at how to cache and share DateFormatters without the bugs that come from them being shared mutable state.
Building a Networking Layer with Operations
Operations have a reputation for being chunky, especially compared to GCD. However, once you get to know operations, you realise that they are the OOP approach to concurrency in iOS. Here, we look at how to use operations to build a networking layer by encapsulating multiple steps into one unit.
Don't Throw Anything Away with Pausable Downloads
Every time a user has to wait for a network request to complete before they can get on with their task, we risk losing them. With pausable downloads, we can ensure that even a cancelled download isn't wasted. Here, we look at how to resume a cancelled download to minimise wait times.
Avoid Queue-Jumping
We are often told that no matter where you end up, you shouldn't forget where you came from. Usually, this saying is applied to people, but it can also apply to code. Here, we look at how to capture the originating thread when kicking off a background task so that we can return to it later.