Fun with Blocks (in Objective-C)

June 28, 2010

I’ve been working on a Mac application recently that’s 10.6-targeted, which has afforded me a multitude of opportunities to use blocks (Apple’s C language extension introduced in Mac OS X 10.6) to get some tricky features written with a level of grace that previously wouldn’t have been possible.

If you’re a Mac or iOS developer and you’re wondering what good blocks are outside of NSOperationQueue/Grand Central Dispatch, or if you’d like to see some fun ways to take advantage of blocks, check out the most recent installment of Ask Big Nerd Ranch on using blocks in Objective-C, authored by yours truly.

BNRBlockView (gist) is my favorite of the bunch, and the NSThread additions are invaluable building blocks (pun not intended, void where prohibited).