Skip to content

Latest commit

 

History

History
58 lines (41 loc) · 946 Bytes

README.markdown

File metadata and controls

58 lines (41 loc) · 946 Bytes

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.