title: KVO Notifications for a Modification of an NSArray backed by a NSMutableArray
body: <p>I am trying to use KVO to listen to collection change events on an NSArray property. Publicly, the property is a readonly NSArray, but is backed by an NSMutableArray ivar so that I can modify the collection.</p>
  
  <p>I know I can set the property to a new value to get a “set” change, but I’m interested in add, remove, replace changes. How do I correctly notify these type of changes for an NSArray?</p>
  
  <pre><code>@interface Model : NSObject
  
  @property (nonatomic, readonly) NSArray *items;
  
  @end
  
  @implementation Model {
      NSMutableArray *_items;
  }
  
  - (NSArray *)items {
      return [_items copy];
  }
  
  - (void)addItem:(Item *)item {
    [_items addObject:item];
  }
  
  @end
  </code></pre>
  
  <p></p>
  
  <pre><code>Model *model = [[Model alloc] init];
  
  [observer addObserver:model 
        forKeyPath:@"items" 
           options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) 
           context:NULL];
  
  Item *item = [[Item alloc] init];
  [model addItem:newItem];
  </code></pre>
  
  <p>Observer class:</p>
  
  <pre><code>-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
      if ([keyPath isEqualToString:@"items"]) {
          //Not called
      }
  }
  </code></pre>