Latest 1.0.5
Homepage https://github.com/mergesort/UIControl-Notifications
License Apache 2.0
Platforms ios 5.0, requires ARC
Frameworks Foundation
Authors

UIControl-Notifications

Make your UIControls respond to notifications and blocks instead of the old fashioned target+selector approach

The blocks portion of the code is based off of the work found here:
http://ioscodesnippet.com/post/22440533385/adding-block-support-for-uicontrols-target-action

The QT framework approaches the UI by decoupling the action and the response. They use signals and slots, in accomplishing this. A class emits a signal, and any slot that is waiting for the signal responds to it. (You can read more about it here: http://doc.qt.digia.com/4.7-snapshot/signalsandslots.html)

NSNotificationCenter is a great parallel to this, and I figured it would be great to have the Cocoa work in such a way, in a standardized fashion. Using this category, you can in one line have a UIControlEvent post a notification (or take in a block to execute), and have any class that’s observing these notifications react accordingly.

It’s as easy as:

[someButton addNotificationNamed:kNotificationName parameters:@{kNotificationEvent_key : kNotificationEvent_value} forControlEvents:UIControlEventTouchUpInside];

And now you have it emitting a notification for anyone to observe.

You can also use:

[someButton addBlock:^(id sender, UIEvent *event) {
    NSLog(@"I've been tapped");
} forControlEvent:UIControlEventTouchUpInside];

If you want to use blocks instead of notifications.

Latest podspec

{
    "name": "UIControl+Notifications",
    "version": "1.0.5",
    "license": {
        "type": "Apache 2.0",
        "file": "LICENSE"
    },
    "homepage": "https://github.com/mergesort/UIControl-Notifications",
    "authors": {
        "Joe Fabisevich": "[email protected]"
    },
    "summary": "Make your UIControls respond to notifications and blocks instead of the old fashioned target+selector approach",
    "source": {
        "git": "https://github.com/mergesort/UIControl-Notifications.git",
        "tag": "1.0.5"
    },
    "source_files": "*.{h,m}",
    "frameworks": "Foundation",
    "requires_arc": true,
    "social_media_url": "https://twitter.com/mergesort",
    "platforms": {
        "ios": "5.0"
    }
}

Pin It on Pinterest

Share This