May 9 11
If you’re working on a complex iOS app, it’s very easy to create a UIViewController subclass with a huge amount of code. One of the many code guidelines I learned at Google was the simple idea of keeping functions and files small. For example, I would recommend trying to keep the vast majority of your […]
January 18 11
This post gives a quick introduction on how to print in iOS 4.2+. There are multiple ways to interact with AirPrint, but for brevity I’ll focus on printing a single PDF document. Â This actually covers a lot of cases, since anything you can draw in Quartz can be drawn into a piece of PDF data […]
December 17 10
In this post, I’ll give a quick overview on choosing a personal coding style, and present a way to auto-format code in bulk. If you take your code seriously, you probably have a code style that you consistently use. For example, maybe you always use braces with every if clause, or you use underscores in […]
June 11 10
This post describes what is needed for any class to work as a key of NSDictionary or NSMutableDictionary. The only thing that is really required is that your class adopt the NSCopying protocol. Â That’s because every key is copied before being added to the dictionary. Â I mention why this design decision was probably made below. […]
April 26 10
This post explains one of my favorite NSObject categories – one that is extremely universal and handy for shorter and, in my opinion, more memory-manageable code.  (Code below.) Edit: Commenter David found a bug in this implementation. Check out the fixed version here; the new source files are listed at the bottom of that post. (The […]
April 4 10
I recently posted an overview of callback mechanisms in Objective-C, including the pros and cons of delegates versus target/action pairs; in this post I’ll introduce a new design pattern that combines many of the benefits of both of these approaches into a single technique. If you’re building a class to be reused many times, it […]