Created
May 17, 2010 11:11
-
-
Save Seasons7/403652 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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