Recent articles
Jump to a random postWhat is Module Stability in Swift and why should you care?
Published on: October 7, 2019The Swift team has recently released Swift 5.1. This version of the Swift language contains many cool features like Function Builders that are used for SwiftUI and Property Wrappers that can be used to add extra functionality to properties. This release also contains a feature called Module Stability. But what is this feature? And what does it mean to you as a developer? In this week’s blog post, I will explain this to you. But before we get to Module Stability, let’s do a little time traveling back to Swift 5.0, which shipped with ABI (Application Binary Interface) Stability. Understanding...
Read more...Finding the difference between two Arrays
Published on: October 6, 2019Many applications work with data, often they are built to retrieve data and display this data to the user in a table view, collection view, list (if you're using SwiftUI) or a different kind of component. It's not uncommon for this data to change and when it does you might be interested in figuring out what elements were added to the data and which items were removed. This isn't always straightforward so up until now you might have written code something like the following: func didFetchNewRecipes(_ newRecipes: [Recipe]) { recipes = newRecipes tableView.reloadData() } Simple and effective, much easier than...
Read more...Getting started with unit testing your Swift code on iOS – part 2
Published on: October 2, 2019In part 1 of this two-part blog post, you’ve learned how to write synchronous unit tests for a login view model. As a reminder, you saw how to implement tests for the following requirements: When both login fields are empty, pressing the login button should trigger an error that informs the user that both fields are mandatory. When one of the two fields is empty, pressing the login button should trigger an error that informs the user that the empty field is mandatory. When the user’s email address does not contain an @ symbol, pressing the login button should trigger...
Read more...Getting started with unit testing your Swift code on iOS – part 1
Published on: September 30, 2019Recently, I ran a poll on Twitter and discovered that a lot of people are not sure how to get started writing tests, or they struggle to get time approved to write tests for their code. In this blogpost, I will take you through some of the first steps you can take to start writing tests of your own and help you pave the way to a more stable codebase. Why bother with tests at all? You might be wondering why you should bother with code that tests your code. When you put it like that, the idea might indeed...
Read more...Supporting Low Data Mode in your app
Published on: September 23, 2019Together with iOS 13, Apple announced a new feature called Low Data Mode. This feature allows users to limit the amount of data that’s used by apps on their phone. The low data mode setting is available in the settings app. Whenever a user is on a slow network, a very busy network or on a network that might charge them for every megabyte they download, users might not want to spend their limited data budget on large fancy images or clever prefetching logic. With Low Data Mode, users can now inform your app that they are on such a...
Read more...Spend less time maintaining your test suite by using the Builder Pattern
Published on: September 16, 2019Often when we write code, we have to initialize objects. Sometimes the object’s initializer doesn’t take any arguments and a simple let object = MyObject() call suffices to create your object, other times things aren’t so simple and you need to supply multiple arguments to an object’s initializer. If you have read my previous post, Cleaning up your dependencies with protocols , you might have refactored your code to use protocol composition to wrap dependencies up into a single object that only exposes what’s needed to the caller. In this blogpost I would like to show you a technique I...
Read more...Cleaning up your dependencies with protocols
Published on: September 9, 2019If you’re into writing clean, testable and maintainable code you must have come across the term “Dependency Injection” at some point. If you’re not sure what dependency injection is, that’s okay. I will explain it briefly so we’re all on the same page before we get to the main point of this post. Dependency Injection in a Nutshell Dependency injection is the practice of making sure that no object creates or manages its own dependencies. This is best illustrated using an example. Imagine you’re building a login page for an app and you have separate service objects for registering a...
Read more...About my iOS development book…
Published on: December 11, 2017It's been almost two years since I blogged on this page. I know, two years is a long break for a person that claims to love "Writing about my everyday coding problems and solutions". Well, there is a very valid reason for my absence because I have been working on a book! Two actually, but they're mostly two sides of the same coin. My first book ever is named "Mastering iOS 10 Programming". It's been published by Packt Publishing and with it you can learn all the awesome new iOS 10 goodies that Apple introduced last year. If you're about...
Read more...Enforcing modular code with frameworks in Xcode
Published on: July 17, 2016Every iOS developer I know dreams of writing code that’s DRY, modular, testable and reusable. While this is a great goal to strive for it’s often quite hard to write code that is completely modular. It just takes one oversight to blow most of the modularity you have achieved right out the window. One technique that people use to make it easier to write modular code is to try and ensure that a certain part of their code, for instance the networking logic or their models, know nothing about other parts of the app. Again, a great idea but this...
Read more...Surviving a start-up’s bankruptcy
Published on: June 13, 2016On a Tuesday almost two months ago, near the end of april, me and my coworkers received an email about an important meeting the next. We knew that something was going on, the look and feel of this email wasn't the same as usual. This one seemed a bit darker, a bit more serious. On Friday you could feel the tension in the office, people were speculating a bit and just acting different than usual. But we all had jobs to do and we tried to do them just like we always did. But it turns out that this tension...
Read more...