https://github.com/sobri909/mgevents
Blocks based keypath, UIControlEvents, and custom event event handlers
https://github.com/sobri909/mgevents
Last synced: about 2 months ago
JSON representation
Blocks based keypath, UIControlEvents, and custom event event handlers
- Host: GitHub
- URL: https://github.com/sobri909/mgevents
- Owner: sobri909
- License: bsd-2-clause
- Created: 2014-06-06T14:18:46.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2018-09-14T12:14:39.000Z (over 6 years ago)
- Last Synced: 2025-03-27T02:38:06.244Z (2 months ago)
- Language: Objective-C
- Homepage:
- Size: 25.4 KB
- Stars: 21
- Watchers: 6
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.markdown
- Changelog: CHANGELOG.markdown
- License: LICENSE
Awesome Lists containing this project
README
## MGEvents
**MGEvents** provides any extremely lightweight API for keypath observing, UIControl event
handling, and observing and triggering custom events.### CocoaPods Setup
```
pod 'MGEvents'
```### Examples
```objc
#import
```### Keypath Observing
```objc
[box onChangeOf:@"selected" do:^{
NSLog(@"the new selected value is: %d", box.selected);
}];
```### Control Event Observing
```objc
[button onControlEvent:UIControlEventTouchUpInside do:^{
NSLog(@"i've been touched up inside. golly.");
}];
```Or in Swift:
```swift
button.onControlEvent(.TouchUpInside) {
print("you touched me!")
}
```### Custom Events and Triggers
```objc
[earth on:@"ChangedShape" do:^{
NSLog(@"the earth has changed shape");
}];
```Then trigger the event:
```objc
[earth trigger:@"ChangedShape"];
```### Further Options
See the [API reference](http://cocoadocs.org/docsets/MGEvents) for more details.