-
Tracking tasks with stack traces in Swift
In this tongue-twister titled article, I discuss capturing control flow information with stack traces during ongoing tasks to aid debugging. Also included: a reimplementation of NSThread.callStackReturnAddresses in Swift for faster and more flexible stack traces. -
Use it or lose it: why safe C is sometimes unsafe Swift
Swift and C have different memory models. This means that using Swift to call C functions in a manner that would be valid in C can cause memory safety problems. I'll show how this can occur with a subtle Release build bug inspired by issues that occurred while writing the previous article. -
Partial functions in Swift, Part 2: Catching precondition failures
Partial functions are risky but if you're going to write one anyway, you should do something completely crazy to test that it is risky in all the right places. -
Partial functions in Swift, Part 1: Avoidance
Partial functions (functions with preconditions) are a risky design choice. You probably have a few in your program, even if you haven't clearly identified them. Learn how to recognize them, learn about their risks, learn to avoid them and learn why you might choose to use them anyway. -
A new era for Cocoa with Love
I'm drawing a line between the old Objective-C era posts on Cocoa with Love and the Swift era posts. The aim of the new era will be to make app programming suck less through a broad theme: "maintainable Cocoa apps". If we program with fewer runtime errors and new features are easier to add, we'll have more fun – even if "maintainable" sounds like a dull word. -
A big weakness in Objective-C's weak typing
We generally assume that we can send any message we want to a variable in our code typed as "id" and Objective-C's dynamic message handling will make the invocation work correctly at runtime. In some rare cases, this assumption is wrong. I'll look at situations where you need to be careful about sending messages to "id" typed variables and a situation where a limitation in the Objective-C language requires a hideous workaround to avoid serious bugs. -
An RSS-feed and location-based iOS application
The purpose of this post is so that I will have a link to give people when they ask: how do I write an iOS application that pulls data from an RSS feed, displays it pretty and can put things on a map. I'll show you all of that and more as I rewrite my oldest iOS application from scratch: FuelView. -
Classes for fetching and parsing XML or JSON via HTTP
In this post I show two reusable classes for fetching data via HTTP: one that parses the result as XML and another that parses as JSON. These are relatively simple tasks but due to the number of required steps, they can become tiresome if you don't have robust, reusable code for the task. These classes will work on iOS or on the Mac but the optional error alerts and password dialogs are only implemented for iOS. -
Presenting a Mac dialog sheet with visual cue effects
In this post, I'll show you how to use visual effects over a window to make a dialog sheet stand out when it is presented over the top. It's a pretty simple use of Core Image but is a useful technique to capture attention when needed. -
Background audio through an iOS movie player
Background audio in iOS is supposed to be as simple as entering a setting in your Info.plist and making sure yourkAudioSessionProperty_AudioCategoryis appropriate. This is true unless your audio is part of a movie file or is played in a movie player that has just played video — suddenly it becomes fiddly, hard to test, unreliable and changeable from version to version of iOS.
Swift era
Objective-C era