How to review a pull request for an iOS app

(or “How to review a merge request” if you’re using GitLab like my team. I’ll use the term “pull request” here.) What should you look for as you’re reviewing a pull request? It’s important to review the code and verify the functionality so you can be sure the change does what it should and doesn’t introduce any new issues. 1. …

When do you use optional chaining vs. if let or guard?

Short answer: I use optional chaining when I don’t really care if the operation fails; otherwise, I use if let or guard. OK, so what does that look like in practice? Let’s look at an implementation of our favorite UITableViewDataSource method, tableView(_cellForRowAt:):

(This example comes straight from the Expanded Edition of Parsing JSON in Swift, so grab that if …

Notifications and Alerts are Disruptive

Supertop: The latest beta release of iOS introduces a new feature that allows developers to prompt users to rate their apps. The rating is selected and submitted without leaving the app. It is presented as an alert, using the standard system appearance. As they go on to say, these are annoying. I agree. iOS already has a feature for communicating …

Improving Swift Compile Times

Let’s face it: there’s a limit to how much fun you can have while you’re waiting for code to compile. (via xkcd.com/303/) At some point, enough is enough. Our team has had enough fun compiling Swift code over the past year that we’ve incorporated the following into our project so we can spend less time compiling and more time working. …

How to parse JSON with Swift 3

Why is it so hard to parse JSON in Swift? I can’t count the number of times I’ve seen or heard this question since Swift came out. So what’s the problem? Shouldn’t a real programming language make it super simple to work with JSON since everyone uses it everywhere? The issue is that we’re taking weakly-typed JSON data and transforming …

Cut your Swift build times in half with this one weird trick

(I’m not apologizing for the clickbaity title since it actually works and it is a little weird…) I’ve been working on improving Swift build times off and on for the past few weeks, and today I stumbled across the best possible improvement: a one-line change that cut our build times in half. I noticed in our build logs that all …

Testing asynchronous code in Swift with XCTest expectations

Testing asynchronous callbacks in your Swift code? Try this:

Consider using OHHTTPStubs or just stubbing manually to make this run faster. (Note that result is a simple Result enum like Rob Napier describes in Functional Wish Fulfillment.)

WWDC 2016 podcast episodes for iOS developers

I enjoy listening to podcasts when I commute, and I especially love hearing different people’s thoughts, opinions, and recommendations on what to do as a result of the new announcements at WWDC. Here are some of the WWDC 2016 podcast episodes I’ve enjoyed, followed by a few that are still on my list. If you’re looking something to listen to …

Key takeaways for iOS developers from the WWDC 2016 Keynote

As a busy iOS developer, it’s hard to find time to sit down and watch a two-hour keynote, even if it is relevant and important. Here’s a summary of what Apple announced in the WWDC 2016 Keynote as it relates to iOS developers. This covers only what’s relevant to you as an iOS developer; it doesn’t cover watchOS 3, macOS …