Latest 1.1.0
Homepage https://github.com/zhooleen/Notifier
License MIT
Platforms ios 7.0
Dependencies KeyPath
Authors
  1. Using RTObserver protocol to uniform the behaviors in notification & KVO
  2. Register observer with block
  3. Unregister the observing action automatically when the observer deallocs
  4. For KVO, when the observed object deallocs, it will remove the observers automatically

Usage

//hold the observer returned by strong reference.
self.observer1 = [self.model observerForKeyPath:@"title" withBlock:^(id changes){}];
[self.observer1 startObserve];

//stop observing
[self.observer1 stopObserve]; //invoke [self.observer1 startObserve] to observe again
/**
 * OR
 */
self.observer1 = nil; //self.observer1 = [...] if you want to observe again

self.model == nil; //stop observing as the observed object deallocs automatically

Latest podspec

{
    "name": "Notifier",
    "version": "1.1.0",
    "summary": "Automatically remove observer and avoid repeat registration for NSNotificationCenter & KVO in Objective-C",
    "description": "Automatically or manually remove observer and avoid repeat registration for NSNotificationCenter & KVO in Objective-C",
    "homepage": "https://github.com/zhooleen/Notifier",
    "license": "MIT",
    "authors": {
        "lzhu": "[email protected]"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/zhooleen/Notifier.git",
        "tag": "1.1.0"
    },
    "source_files": [
        "Classes",
        "Classes/**/*.{h,m}"
    ],
    "exclude_files": "Classes/Exclude",
    "dependencies": {
        "KeyPath": []
    }
}

Pin It on Pinterest

Share This