In my iOS adventures, I got really into blocks, because they were necessary for the UIViewAnimation to “Animate With Blocks” which is the recommended way to do UIView animations. Of course, this results in code that is not backwards compatible. I realize this question has a subjective component, but at what point would using the iOS 4.0 code only be a good idea? Or would differential code be a good idea, and how would that be achieved in objective-c?
I’m now faced with redoing my code for iOS 3.0, which is a painful task: should I just keep my “blocks” code around until the world advances?
See Plausible Blocks for a port of the blocks runtime to 10.5/iPhone OS 3. It might be easier than rewriting your code, though you’ll have to implement and add the relevant animation methods to UIView’s metaclass on 3.0 (hint:
class_addMethod()).I don’t think we’ll be dropping OS 3 support for another 6-9 months, depending on adoption (especially considering that the iPad is still stuck on 3.2.1).
There’s also no easy way to replicate
setAnimationWillStartSelector:with the block-based animation API. I’ve used it to sync sounds to animations (you can’t just play the sound, because the animation doesn’t start until after view layout/image loading finishes).