Skip to content

Instantly share code, notes, and snippets.

@Seasons7
Created May 17, 2010 11:11
Show Gist options
  • Save Seasons7/403652 to your computer and use it in GitHub Desktop.
Save Seasons7/403652 to your computer and use it in GitHub Desktop.
// self.nameが新しい値に更新されると呼び出される
KVOBlock blockFunc = ^(
NSString *keyPath,
id object,
NSDictionary *change,
id identifier)
{
NSString *text = [change valueForKey:@"new"];
// 変更された値で書き換え
// とりあえず、ラベルとボタンのタイトルを一気に変更的な
_label.text = text;
[_button setTitle:text forState:UIControlStateNormal];
};
// 通知に登録
[self addObserver:self
handler:blockFunc
forKeyPath:@"name"
options:NSKeyValueObservingOptionNew
identifier:NULL];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment