LoginSignup
6
6

More than 5 years have passed since last update.

キー値監視(KVO)

Posted at

オブジェクトのプロパティ値が変更されたのを検出できます。

{
    [obj addObserver:self forKeyPath:@"prop" options:NSKeyValueObservingOptionNew context:nil];
}

- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    if ([keyPath isEqualToString:@"prop"]) {
        // object.propが更新された.
    }
}
6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6