Code Snippet

5 Nov 2012

Mistakes Were Made: Audio and ARC

ARC silently kills your AVAudioPlayer mid-playback. Here’s why and how to fix it. Spoiler: make it an ivar, and maybe file a radar while you’re at it.

27 Aug 2012

Premature Completion: An Embarrassing Problem

Core Animation runs your completion block early if it doesn’t find any animations. Rude. Includes a sample project to poke at the behavior yourself and avoid hours of confused debugging.

12 Dec 2011

Cancel dispatch_after

A simple wrapper to cancel delayed blocks, because GCD won’t let you. Includes the open-source code on GitHub and a look under the hood at the block-juggling trick that makes it work.

5 Oct 2011

Mistakes Were Made: Integral Bounds

Non-integral CALayer bounds don’t just look blurry — they actually chop off pixels. A forensic look at CATextLayer backing stores, with screenshots and sample code to prove it.

15 Aug 2011

Quick Tip: Drawing Right Side Up With Core Text

Why Core Text draws everything upside down on iOS and how to fix it. A quick walkthrough of context transforms, text matrices, and why CGContextSetTextMatrix alone won’t save you.