Frame geometry macros to improve your UIKit code
I find myself doing more and more dynamic UI layout in iOS apps these days. When elements of a UI need to resize to fit their contents, or move to accommodate other elements, the layout code can get complex and verbose. We’ve developed a set of Objective-C UIKit macros that help make this code more […]
Objective-C Singleton Pattern Updated For Testability
At Two Bit Labs we do a fair amount of unit testing. In places where we use singletons we use a variation on the the Objective-C dispatch_once pattern of thread safe singleton creation. This variation supports resetting the singleton or replacing it with a mock object. That way in our unit tests we can do […]
Kickstart your apps with the iOS Xcode Starter Project
We created the iOS Xcode Starter Project to make it quick and easy to start a new iPhone or iPad app. Our goal was to create a template to save the hours of effort it takes on a new project configuring essential open source libraries, the unit and functional testing environments, analytics, multiple targets, multiple […]
Block initialization for testability and reuse
Since Apple introduced block support in iOS 4, more and more APIs are moving from delegation to block callbacks. While block callbacks can be declared inline, in most cases you should initialize your block callback in a method that returns the block. This keeps the code that calls an external API succinct, allows you to […]
The reviews are in!
So be honest: What’s your answer to the question “Do you enjoy reading the latest app store reviews for your app?” (a) “Our users are so smart, kind, and thoughtful that I relish the chance to read their pearls of wisdom.” (b) “Unless they’re written on the bottom of a pint glass, no.” (c) “I’d […]
Enable memory warnings in the iOS simulator to catch crash issues
One common crash issue that’s tough to catch during iOS development of UIViewControllers is the unloading and re-loading of views due to memory warnings. The viewDidUnload method ONLY gets called when a memory warning comes in, NOT as part of the regular view lifecycle. During development it’s likely you may never get a memory warning, […]
Reduce iOS memory utilization by taming NSURLCache
If your iPhone or iPad app embeds UIWebViews or makes HTTP requests directly with NSURLConnection, it’s important to keep an eye on memory utilization by running it through the profiler occasionally. Web requests can use a lot of memory, and you may find the memory footprint grows and grows the more you use the app. […]
Initializing UIViewControllers
Most code samples that Apple provides for initializing a view controller look something like this: 
MyController *myController = [[MyController alloc] initWithNibName:@"MyView" bundle:nil]; This always felt like a strange pattern to me. And as Ole Begemann recently pointed out, it’s poor encapsulation. Why does the caller specify which .xib file some other controller should use? Isn’t […]
Symbolicating (mostly) fixed in Xcode 4.1
I previously posted why Xcode 4’s symbolication is broken, along with a patched script that fixes it. As of Xcode 4.1, Apple has fixed the problems in the symbolicatecrash script, though I’ve found that it still often does not symbolicate correctly. Here are the most common problems (and solutions) I’ve come across:
Using DiffMerge as your Git visual merge and diff tool
Our favorite (and free) visual diff and merge tool for OS X (as well as Linux and Windows) is DiffMerge. It makes resolving nasty Git branch conflicts a snap (relatively speaking). Here’s how to install it and configure it with Git on OS X: Download the DiffMerge OS X installer. Be sure to download the […]