Skip to content

ALActionBlocks Category on UIControl, UIBarButtonItem, and UIGestureRecognizer to allow use of blocks instead of selectors.

License

Notifications You must be signed in to change notification settings

WhoopInc/ALActionBlocks

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ALActionBlocks

This is a fork of ALActionBlocks, forked from https://github.com/lavoy/ALActionBlocks to use as a Swift Package.

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] (https://github.com/davedelong)'s StackOverflow [answer] (http://stackoverflow.com/a/4582061/315074).

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.

Requirements

ALActionBlocks is compatible with iOS 5.0 and above.

ARC

Yuuuup!

Creator

Andy LaVoy
@lavoy

License

ALActionBlocks is available under the [MIT] (http://opensource.org/licenses/MIT) license.

About

ALActionBlocks Category on UIControl, UIBarButtonItem, and UIGestureRecognizer to allow use of blocks instead of selectors.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 93.1%
  • Swift 4.8%
  • C 2.1%