So you’re all pumped up about this deft-sounding “Block” (aka Closure) concept that Grand Central Dispatch is going to bring to us in Snow Leopard … but it’s not out yet, and Snow Leopard does not run on the iPhone! So what do you do?
Well, if you’re really excited, you … implement it yourself.
If you caught the sessions on blocks at WWDC, you may be as excited as
I am to make use of them. Unfortunately, they’re only available for
Snow Leopard.As a result, I decided to back-port block support to iPhoneOS 3.0 and
Mac OS X 10.5…
Dude. That’s hardcore. Here’s the announcement of Plausible Blocks; project page on Google Code; and a tutorial demonstrating its use with NSOperationQueue and UIActionSheet with sample code on github. Enjoy!
UPDATE — More good posts on blocks:
Using Blocks: Understanding the Memory Management Rules
Blocks, Episode 2: Life Cycles
UPDATE 2 — Recommendations from the 1.0 release announcement:
Joachim Bengtsson’s Programming with C Blocks
Mike Ash’s Series on Blocks, Part I
Mike Ash’s Series on Blocks, Part II
Landon Fuller’s Using Blocks 1 (as mentioned above)
Landon Fuller’s Using Blocks 2
h/t: iPhoneSDK!
JUL