title: Getting "mutating method sent to immutable object" error
body: <p>I can't figure out what is causing this. Basically, a few different 'tasks' are colliding with each other in my app. When i press a button, it runs this code just fine:</p>
  
  <pre><code>PalAppDelegate *dataCenter = (PalAppDelegate *)[[UIApplication sharedApplication] delegate];
  
  
  
  
  [dataCenter.colourPalettesContainer addObject:[NSNumber numberWithInt:5]];
  </code></pre>
  
  <p>It can do this as many times as i like. But when i perform another task (and theres a few which cause this to happen), which involves this code for example:</p>
  
  <pre><code>PalAppDelegate *dataCenter = (PalAppDelegate *)[[UIApplication sharedApplication] delegate];
  
  [dataCenter.colourPalettesContainer removeObjectAtIndex:touchDownID];
  
  NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
  [prefs setObject:dataCenter.colourPalettesContainer forKey:@"container"];
  [prefs synchronize];
  </code></pre>
  
  <p>and then:</p>
  
  <pre><code>dataCenter.colourPalettesContainer = [prefs objectForKey:@"container"];
  </code></pre>
  
  <p>When i run the first code again after this, it causes a crash with the "mutating method sent to immutable object" error. How can i stop this?</p>
  
  <p>EDIT: So i've found out the problem from some answers below. Does anybody have a different method of doing this which they'd suggest?</p>