title: "Mutating method sent to immutable object" despite object being NSMutableDictionary
body: <p>I'm using <code>NSMutableDictionary</code> and hit this error:</p>
  
  <pre><code>'NSInternalInconsistencyException', reason: '-[__NSCFDictionary removeObjectForKey:]: mutating method sent to immutable object'
  </code></pre>
  
  <p>Here's the code:</p>
  
  <pre><code>    // Turn the JSON strings/data into objects
      NSError *error;
      NSMutableDictionary *invoiceDictFromReq = [[NSMutableDictionary alloc] init];
  //    invoiceDictFromReq = (NSMutableDictionary *)[NSJSONSerialization JSONObjectWithData:[request responseData] options:kNilOptions error:&amp;error];
      invoiceDictFromReq = [NSMutableDictionary dictionaryWithDictionary:[NSJSONSerialization JSONObjectWithData:[request responseData] options:kNilOptions error:&amp;error]];
  
  NSLog(@"invoiceDictFromReq count: %i, key: %@, value: %@", [invoiceDictFromReq count], [invoiceDictFromReq allKeys], [invoiceDictFromReq allValues]);
  
  // Get values and keys from JSON response
  self.invoiceDict = [invoiceDictFromReq objectForKey:@"invoice"];
  NSNumber *invoiceAmount = [self.invoiceDict objectForKey:@"amount"];
  NSNumber *invoiceId = [self.invoiceDict objectForKey:@"id"];
  NSNumber *invoiceNumber = [self.invoiceDict objectForKey:@"number"];
  NSNumber *checkoutStarted = [self.invoiceDict objectForKey:@"checkoutStarted"];
  NSNumber *checkoutCompleted = [self.invoiceDict objectForKey:@"checkoutCompleted"];
  NSLog(@"amount: %@, id: %@, number: %@, started: %@, completed: %@", invoiceAmount, invoiceId, invoiceNumber, checkoutStarted, checkoutCompleted);
  </code></pre>
  
  <p>All the console logs indicate that the data is fine. This is where things start to break down.
  I pass the <code>invoiceDict</code> property to the next view controller:</p>
  
  <pre><code>// Pass the invoice to checkoutViewController
  [checkoutViewController setInvoiceDict:self.invoiceDict];
  </code></pre>
  
  <p>In CheckoutViewController.m:</p>
  
  <pre><code>    // Change invoice checkoutCompleted to true
  //    [self.invoiceDict removeObjectForKey:@"checkoutCompleted"];
      [self.invoiceDict setObject:[NSNumber numberWithBool:YES] forKey:@"checkoutCompleted"];
  </code></pre>
  
  <p>The error is at <code>[self.invoiceDict setObject...]</code>. I made sure that all the dictionaries I use are <code>NSMutableDictionary</code>. I left some of the commented-out lines in the code to show the things I've tried and I hit a brick wall. I suppose I can always create a new dictionary. Is that the preferred way to do it?</p>