nickpaulson/BlockKit — pull request #8 by alexdeem (2011-12-11 12:29:28+00:00)
Title: Fix issue which would result in UIControl being accessed after it is dealloc'd 

If the UIControl is dealloc'd from within the dealloc method of one of it's Targets a problem would occur where the UIControl was accessed after its dealloc. This situation is a very common pattern, for example a UIControl having it's superview as a target.

In this situation, removeAllActionBlocks would be called from within one of the UIControl's targets dealloc method. We would then create an autoreleased set that contains this target. Thus the target's release method would be called when the autorelease pool is released. If this happens after the completion of the dealloc method, the call would be on an object that has been dealloc'd. To ensure this is not the case, we wrap the removeAllActionBlocks method in an autorelease pool.

Unfortunately it is not simply a matter of using -[release] instead of -[autorelease] as self.allTargets is also creating an autoreleased set that contains the target.