Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lavoy/ALActionBlocks
ALActionBlocks Category on UIControl, UIBarButtonItem, and UIGestureRecognizer to allow use of blocks instead of selectors.
https://github.com/lavoy/ALActionBlocks
Last synced: 3 months ago
JSON representation
ALActionBlocks Category on UIControl, UIBarButtonItem, and UIGestureRecognizer to allow use of blocks instead of selectors.
- Host: GitHub
- URL: https://github.com/lavoy/ALActionBlocks
- Owner: lavoy
- License: mit
- Created: 2013-03-30T16:01:32.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2022-06-11T12:22:45.000Z (over 2 years ago)
- Last Synced: 2024-10-31T15:47:59.252Z (3 months ago)
- Language: Objective-C
- Homepage:
- Size: 300 KB
- Stars: 227
- Watchers: 13
- Forks: 23
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - ALActionBlocks - ALActionBlocks Category on UIControl, UIBarButtonItem, and UIGestureRecognizer to allow use of blocks instead of selectors. (etc)
- awesome - ALActionBlocks - ALActionBlocks Category on UIControl, UIBarButtonItem, and UIGestureRecognizer to allow use of blocks instead of selectors. (etc)
README
# ALActionBlocks
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 UIGestureRecognizerThis category was inspired by [Dave DeLong] (https://github.com/davedelong)'s StackOverflow [answer] (http://stackoverflow.com/a/4582061/315074).
#### Simple Example
```objc
#import "ALActionBlocks.h"
```
```objc
// Assuming you have a UIButton named 'button'
[button handleControlEvents:UIControlEventTouchUpInside withBlock:^(id weakControl) {
NSLog(@"button pressed");
}];
```#### Removing Blocks
```objc
[button removeActionBlocksForControlEvents:UIControlEventTouchUpInside];
```That's it!
*Check out the demo project for more details.*
#### Requirements
ALActionBlocks is compatible with [iOS 5.0](http://developer.apple.com/library/ios/#releasenotes/General/WhatsNewIniOS/Articles/iOS5.html) and above.
### ARC
Yuuuup!
### Creator
[Andy LaVoy](http://github.com/lavoy)
[@lavoy](https://twitter.com/lavoy)### License
ALActionBlocks is available under the [MIT] (http://opensource.org/licenses/MIT) license.