title: NSMutableArray can't be added to
body: <p>I've had this sort of problem before, and it didn't get a satisfactory answer. </p>
  
  <p>I have a viewcontroller with a property called "counties" that is an NSMutableArray. I'm going to drill down a navigation screen to a view that is about selecting the counties for a geographical search. So the search page drills down to the "select counties" page.</p>
  
  <p>I pass <code>NSMutableArray *counties</code> to the second controller as I push the second one on the navigation stack. I actually set that second controller's "selectedCounties" property (also an NSMutableArray) with a pointer to my first controller's "counties", as you'll see below. </p>
  
  <p>When I go to <code>addObject</code> to that, though, I get this:</p>
  
  <pre><code>*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '*** -[NSCFArray insertObject:atIndex:]: mutating method sent to immutable object'
  </code></pre>
  
  <p>Here's my code:</p>
  
  <p>in SearchViewController.h:</p>
  
  <pre><code>@interface SearchViewController : UIViewController 
  {
      ....
      NSMutableArray *counties;
  }
  
  ....
  @property (nonatomic, retain) NSMutableArray *counties;
  </code></pre>
  
  <p>in SearchViewController.m:</p>
  
  <pre><code>- (void)getLocationsView
  {
      [keywordField resignFirstResponder];
      SearchLocationsViewController *locationsController = 
              [[SearchLocationsViewController alloc] initWithNibName:@"SearchLocationsView" bundle:nil];
      [self.navigationController pushViewController:locationsController animated:YES];
      [locationsController setSelectedCounties:self.counties];
      [locationsController release];
  }
  </code></pre>
  
  <p>in SearchLocationsViewController.h:</p>
  
  <pre><code>@interface EventsSearchLocationsViewController : UIViewController 
      &lt;UITableViewDelegate, UITableViewDataSource&gt;
  {
      ...
      NSMutableArray *selectedCounties;
  
  }
  
  ...
  @property (nonatomic, retain) NSMutableArray *selectedCounties;
  </code></pre>
  
  <p>in SearchLocationsViewController.m (the point here is, we're toggling each element of a table being active or not in the list of selected counties):</p>
  
  <pre><code>-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  {
      UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
      if ([self.selectedCounties containsObject:[self.counties objectAtIndex:indexPath.row]]) {
          //we're deselcting!
          [self.selectedCounties removeObject:[self.counties objectAtIndex:indexPath.row]];
          cell.accessoryView = [[UIImageView alloc]
                                initWithImage:[UIImage imageNamed:@"red_check_inactive.png"]];
      }
      else {
          [self.selectedCounties addObject:[self.counties objectAtIndex:indexPath.row]];
          cell.accessoryView = [[UIImageView alloc]
                                initWithImage:[UIImage imageNamed:@"red_check_active.png"]];
      }
      [tableView deselectRowAtIndexPath:indexPath animated:YES];
  }
  </code></pre>
  
  <p>We die at <code>[self.selectedCounties addObject....</code> there.</p>
  
  <p>Now, when I NSLog myself <code>[self.selectedCounties class]</code>, it tells me it's an NSCFArray. </p>
  
  <p>How does this happen? I understand about class bundles (or I THINK I do anyway), but this is explicitly a specific type, and it's losing it subclassing at some point in a way that kills the whole thing. I just completely don't understand why that would happen.</p>