title: Enable/disable a button based on count in NSMutableArray
body: <p>I have a view controller with a button that I'd like to enable if <code>myArray.count &gt; 0</code>. I got KVO working initially, but it doesn't update. </p>
  
  <p>My button property declared here:</p>
  
  <pre><code>@property (strong, nonatomic) IBOutlet UIBarButtonItem *saveButton;
  </code></pre>
  
  <p>I'd like to enable/disable the button based on the count of items in an array:</p>
  
  <pre><code>@property (nonatomic, strong) NSMutableArray *myArray;
  </code></pre>
  
  <p>Items are added/removed to the array via <code>didSelectRowAtIndexPath</code></p>
  
  <p>I found a couple of posts on the topic of observing an NSMutableArray, every post I've seen seems enormous amount of code to implement something so simple.</p>
  
  <p>I added this to <code>viewDidLoad</code> after <code>myArray</code> is instantiated:</p>
  
  <pre><code>// Add KVO for array
  [self.saveButton addObserver:self forKeyPath:@"myArray" options:(NSKeyValueObservingOptionInitial) context:nil];
  </code></pre>
  
  <p>I added this method to do something when there's a change to <code>myArray</code>:</p>
  
  <pre><code>- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
      if ([keyPath isEqualToString:@"myArray"]) {
          if (self.myArray.count &gt; 0) {
              NSLog(@"KVO: myArray.count &gt; 0");
              [self.saveButton setEnabled:YES];
          } else {
              NSLog(@"KVO: myArray.count is ZERO");
              [self.saveButton setEnabled:NO];
          }
      }
  }
  </code></pre>
  
  <p>I know I'm missing something simple, but what is proving elusive.</p>