Song of Myself
Rich Wardwell talks about the weakSelf dance:
The best way to handle retain cycles in blocks is to prevent the cycle from occurring in the first place. Using the
weakSelfdance is easy.
Like Rich and probably everybody else, I love blocks. I couldn’t go back.
The weakSelf thing is the least lovely part of blocks, though. The second least-lovely is the syntax: I rely on auto-complete and fuckingblocksyntax.com, which I’ve bookmarked. (Neither of these puncture my big red balloon of affection for blocks.)
Some things I’ve noticed about my own use of blocks:
Almost all of my blocks are stack-based. I rarely copy a block and assign it to a property. (Not never, though.)
I can often avoid the weakSelf dance by thinking about what’s really needed. My first thought is always that self is somehow needed — but that often turns out not to be true. (Not always.)
I never use
Update 12:25 pm: Kyle Sluder says:
I’d say the least lovely part about blocks is the automatic temporary shadow variables clobbering data: http://llvm.org/bugs/show…