title: Key-Value-Observing a to-many relationship in Cocoa
body: <p>I am trying to get key-value-observing to work for an NSMutableArray. Below is the .h file for MyObservee, the observed class:</p>
  
  <pre><code>@interface MyObservee : NSObject {
      @private int someValue;
      @private NSMutableArray *someArray;
  }
  
  @property (readwrite,assign) int someValue;
  - (NSMutableArray *)someArray;
  @end
  </code></pre>
  
  <p>The class MyObserver implements observeValueForKeyPath:ofObject:change:context:. Here is how I add the observer:</p>
  
  <pre><code>MyObservee *moe = [[MyObservee alloc] init];
  MyObserver *mobs = [[MyObserver alloc] init];
  
  [moe addObserver:mobs 
        forKeyPath:@"someArray" 
           options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) 
           context:NULL];
  
  [moe.someArray addObject:@"hi there"];
  </code></pre>
  
  <p>How come the addObject: message isn't triggering as a change to the someArray key path? I have a feeling there's something I don't fully understand here.</p>