bits about life, coding and stuff
It took a while to get my head around blocks. And it didn’t help that they are not officially available on the iPhone. But savvy devs from Plausible Labs back-ported the GCC extensions that were added to support blocks to the iPhone. And it’s AppStore-safe and they are developing it actively, now adapting it for the iPad. (I already blogged about it)
Today I coded the first actually useful component for blocks. PSAlertView – a wrapper for UIAlertView, no more need for custom delegates. It’s so natural if you think about it.
Some code so you get the idea:
No more custom delegates, no need to set the protocol in the class header. You can use variables from the function surrounding the block (message) and there’s no performance impact.
PSAlertView is loosely based on PLActionSheet, thanks to Landon Fuller for the tutorials.
Related posts:
2 Responses to Blocks on the iPhone – PSAlertView
alex
March 18th, 2010 at 4:55 pm
Great extension, looks a lot like the action-pattern, enriched with the possibility of a more complex code within a block.
So that’s the convenient example of “blocks” we were looking for back in the fall of ’09.
studpete
March 19th, 2010 at 3:43 pm
yeah. once you get your head around it, you wonder why it wasn’t there all the time.