May 30 10
NSTimers usually don’t fire when the user is scrolling a table or other UIScrollView – or doing anything else that puts the run loop in event tracking mode. This post describes the problem and an easy solution. The problem Suppose you set up a timer in the most convenient manner, with something like this: [NSTimer [...]
May 23 10
In this post, I’ll outline four simple rules for memory management in Objective-C. The Apple docs have already established basic guidelines for object ownership, following the fundamental idea that if you own an object, then you’re responsible for releasing it. This post goes a step further with tips for when and where ownership can be [...]
May 11 10
Ok, I admit it – my favorite debugging tool is still NSLog (and print statements in general). In this post I’ll mention some useful debug logging techniques you can use with the help of preprocessor macros. Logging method calls It’s as simple as this: #define PrintName NSLog(@”%s”, __FUNCTION__) Add this macro (with a semicolon) to [...]
May 8 10
In this post, I’ll explain how to add a border, rounded corners, and drop shadow to any UIView using some simple CALayer properties. I’m not a CALayer guru, but these few tricks from the layer world are particularly nice to know about. These properties are present for every UIView, since every view is actually drawn [...]
May 5 10
UILabel is built with a handy shadow feature, but it doesn’t always look the way you might want – in this post I’ll describe the ShadowedLabel subclass which draws nicer shadows. (Code links below.) Default UILabel shadows This code: generates a shadow that looks like this: It’s not the end of the world, but it’s [...]
May 2 10
In this post, I’ll present a microclass that can give you simplified popover ( UIPopoverController ) handling in many cases, including automatic rotation updates. Links to code below. What PopoverHelper does Normally, this is how you need to work with a popover: Set up the content view controller that will appear in the popover. Alloc [...]