sobri909 / MGEvents

Blocks based keypath, UIControlEvents, and custom event event handlers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MGEvents

MGEvents provides any extremely lightweight API for keypath observing, UIControl event handling, and observing and triggering custom events.

CocoaPods Setup

pod 'MGEvents'

Examples

#import <MGEvents/MGEvents.h>

Keypath Observing

[box onChangeOf:@"selected" do:^{
    NSLog(@"the new selected value is: %d", box.selected);
}];

Control Event Observing

[button onControlEvent:UIControlEventTouchUpInside do:^{
    NSLog(@"i've been touched up inside. golly.");
}];

Or in Swift:

button.onControlEvent(.TouchUpInside) {
    print("you touched me!")
}

Custom Events and Triggers

[earth on:@"ChangedShape" do:^{
    NSLog(@"the earth has changed shape");
}];

Then trigger the event:

[earth trigger:@"ChangedShape"];

Further Options

See the API reference for more details.

About

Blocks based keypath, UIControlEvents, and custom event event handlers

License:BSD 2-Clause "Simplified" License


Languages

Language:Objective-C 97.1%Language:Ruby 2.9%