I've written on a pitfall of Objective-C blocks. Blocks implicitly retain the objects referenced inside them, and that can cause all kinds of problems.
Mark Dalrymple has written on the same topic, and his emphasis is on using self
. He came up with a "lighter" solution without resorting to an NSValue object: Use the __block
storage class.
Read his blog entry in full to understand the issue better. I highly suspect this issue will be with us for a long time. I don't think GC will rescue us all: Apple's GC is so buggy to the extent that it's totally unusable in some applications, and it's not available to iOS at least at the current version. The only hope to mitigate the problem is for the static analyzer to be able to warn the dangers ahead.