title: NSMutableArray of NSMutableArrays. Mutating method sent to immutable object
body: <p>I have <code>NSMutableArray</code> of <code>NSMutableArrays</code>:</p>
  
  <pre><code> NSMutableArray *array = [[NSMutableArray alloc]init];
  
          for (int i = 0; i &lt; 5; i++)
          {
              NSMutableArray *miniArray = [[NSMutableArray alloc]init];
  
              for (int k = 0; k &lt; 30; k++)
              {   
                  [miniArray addObject:@"0"];
              }
              [array addObject:miniArray];
          }
  </code></pre>
  
  <p>Then, when I try to do this:</p>
  
  <pre><code> [[array objectAtIndex:packIndex]replaceObjectAtIndex:index withObject:@"1"];
  </code></pre>
  
  <p>it crashes with: <code>[__NSCFArray replaceObjectAtIndex:withObject:]: mutating method sent to immutable object'</code></p>
  
  <p>Why ? How to fix ? Thanks !</p>
  
  <p><strong>UPD</strong>: 
  I save this array in <code>NSUserDefaults</code>:</p>
  
  <pre><code>[defaults setObject:array forKey:@"mainArray"];
  </code></pre>
  
  <p>Then, I read it in the other class:</p>
  
  <pre><code>array = [[NSMutableArray alloc]initWithArray:[[NSUserDefaults standardUserDefaults] objectForKey:@"mainArray"]];
  </code></pre>
  
  <p>Also, I must to mention that sometimes the code runs well and it changes "0" to "1". But it also crashes sometimes. So I cant see the logic, why it works fine or why it crashes sometimes.</p>