Objective c 如何检查数组字典Objective中的键值?

Objective c 如何检查数组字典Objective中的键值?,objective-c,key-value-observing,Objective C,Key Value Observing,我有以下代码: @property (strong, nonatomic) NSMutableDictionary *todoSessionDict; @synthesize todoSessionDict; [self addObserver:self forKeyPath:@"todoSessionDict" options:NSKeyValueObservingOptionNew context:NULL]; -(void)observeValueForKeyPath:(N

我有以下代码:

 @property (strong, nonatomic) NSMutableDictionary *todoSessionDict;
    @synthesize todoSessionDict;

[self addObserver:self forKeyPath:@"todoSessionDict" options:NSKeyValueObservingOptionNew context:NULL];


-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {

}

------------------------
NSMutableArray *unCompletedTodosArr = [NSMutableArray  array];
NSMutableArray *completedTodosArr   = [NSMutableArray  array];

 [self.todoSessionDict setObject:unCompletedTodosArr forKey:@"unCompletedTodosArr"];
 [self.todoSessionDict setObject:completedTodosArr forKey:@"completedTodosArr"];

您知道如何使用
KVO

检查
@“unCompletedTodosArr”和@completedTodosArr”值在
self.todoSessionDict
中是否发生了更改吗?首先,它应该是:

 [self addObserver:self forKeyPath:@"todoSessionDict.unCompletedTodosArr" options:0 context:nil];
  [self addObserver:self forKeyPath:@"todoSessionDict.completedTodosArr" options:0 context:nil];
对于这两种方法:

  #pragma mark - KVO
   -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
   {
     // Here your actions depends on the key path...
    }

    -(void)didChangeValueForKey:(NSString *)key

     {

     }