KVOHelper 1.0.0

KVOHelper 1.0.0

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2014

Maintained by Unclaimed.


Downloads

Total77
Week0
Month0

Installs

Apps7
powered by Segment

GitHub

Stars8
Watchers2
Forks0
Issues0
Contributors1
Pull Requests0

Code

Files2
LOCLines of Code 21


KVOHelper 1.0.0

  • By
  • zhangchiqing

Make iOS Key-Value Observing programming easier

How to use KVOHelper?

#import "KVOHelper.h"

- (id)init {
    if (self = [super init]) {
        [KVOHelper mixinHandlerToKVOContextForClass:self.class];

        [self.account addObserver:self forKeyPath:@"name" options:0 context:@selector(onAccountNameChanged:)];

        self.account.name = @"My Account"; // this will trigger onAccountNameChanged:
    }
    return self;
}

- (void)onAccountNameChanged:(NSDictionary)change {
    NSString *accountName = [change objectForKey:@"new"];
    self.accountNameLabel.text = [NSString stringWithFormat:@"%@", accountName];
}