How to handle null JSON values in Swift

A Parsing JSON in Swift reader recently wrote in and asked: I did have a question regarding getting a null value in your JSON. I know null is different than a nil value so I didn’t know how to go about safely receiving it? So what do you do if you get a null value in your JSON? How do …

Debunking the myths about parsing JSON in Swift

There are a bunch of myths out there about parsing JSON in Swift. And the problem with these myths is that they lead us to solve imaginary problems using bloated frameworks or wacky techniques that gain us very little, especially considering the cost they impose on us. Here are a few of the most popular myths — and the truth …

Year in Review 2015: The Year of Parsing JSON in Swift

I enjoy reflecting and writing these articles each year, and while I write them for myself, others have told me they enjoy reading them. If you missed previous years, you can find them here: 2014: What I learned about building an audience, selling products, and productized consulting 2013: What I learned from launching one failed and one successful product (and …

Reducing clutter in your JSON parser through proper typing

This article is an excerpt from Parsing JSON in Swift. When you’re casting types as you parse your JSON, be as specific as you can to reduce clutter. This is especially important when working with arrays, which generally contain just one type. Let’s look at how we might parse the following JSON (from the GitHub Search Repositories API):

For …

How to test your JSON parser

Earlier, we discussed why you should test your JSON parser and how it can save time, catch bugs, and help you build confidence that your code does what you want. But how do you write tests for your JSON parser? And should you make network requests to the API in your tests? Let’s answer the second question first. Should you …

Why test your JSON parser?

One of the big benefits to creating a separate JSON parser class is that we can write automated tests for it easily. But why would you want to write tests? What benefit could they possibly provide? Unit tests provide at least five main benefits: they help you ensure correctness during development, catch bugs in existing features, allow you to refactor …

APOD App Rejection: Postmortem

My heart sank when I saw the little red dot in iTunes Connect. Apple had just rejected my app. I spent a good portion of my free time during the previous five weeks building my app for the new Apple TV and submitted it just ten hours after they opened submissions. (If I hadn’t been sleeping, I would’ve submitted it …

How to parse JSON with Swift 2

I’ve written about how to parse JSON in Swift before, but someone asked recently about how to do it with Swift 2 and I realized that everything changed from Swift 1.2 to Swift 2.0. So how do you parse JSON with Swift 2? We’ll look at how to parse a JSON array that we could use to display a list …

Notes from WWDC 2015: Building Watch Apps

If you were too slammed to pay attention to WWDC this year, you can get a quick overview of how to build apps for watchOS 2 with the notes below. The Building Watch Apps session from WWDC 2015 is essential for digging in to how development works in watchOS 2. It’s changed significantly from the first version of watchOS, so …

Which books should I get to learn iOS?

You’ve watched plenty of YouTube tutorials on iOS development but feel like you’re not really learning what the code does. Sure, you can write a bit of Swift, but you want to dig deeper to learn how and why the code works. Which books should you use to actually learn iOS so you can build your own apps from scratch? …