Delayed Perform in Cocoa
A while ago I wrote a little proxy class for myself that coalesces messages sent to an object. It used an NSTimer and pushed back its fire time to reusably implement a common performance optimisation. Now, Apple's article on optimising Cocoa code tells me there's a much simpler way already built into Cocoa:
// Cancel the old request
[NSObject cancelPreviousPerformRequestsWithTarget:myTableView selector:@selector(reloadData) object:nil];
// Initiate a new request after a brief delay.
[myTableView performSelector:@selector(reloadData) withObject:nil afterDelay:0.3];
Drat. I'd completely forgotten about that call since I first stumbled across it thinking "What could I use that for...?"