ALActionBlocks Category on UIControl, UIBarButtonItem, and UIGestureRecognizer to allow use of blocks instead of selectors.
Objective-C Ruby
Switch branches/tags
Latest commit 6ebc10e Jan 14, 2014 @lavoy happy new year


ALActionBlocks is an Objective-C category on UIControl, UIBarButtonItem, and UIGestureRecognizer that allows for handling of control events with blocks.

  • Handle control events with blocks
  • Remove blocks for control events
  • Gives you a weak reference to your control in the block
  • Works with all of your existing subclasses of UIControl, UIBarButtonItem, and UIGestureRecognizer

This category was inspired by [Dave DeLong] ('s StackOverflow [answer] (

Simple Example

#import "ALActionBlocks.h"
// Assuming you have a UIButton named 'button'
[button handleControlEvents:UIControlEventTouchUpInside withBlock:^(id weakControl) {
    NSLog(@"button pressed");

Removing Blocks

[button removeActionBlocksForControlEvents:UIControlEventTouchUpInside];

That's it!

Check out the demo project for more details.


ALActionBlocks is compatible with iOS 5.0 and above.




Andy LaVoy


ALActionBlocks is available under the [MIT] ( license.