title: NSMutableArray: addObject "nil"?
body: <p>I am having troubling adding "nil" at the end of an array, I get "NSInvalidArgumentException" ?</p>
  
  <pre><code>NSMutableArray *k = [NSMutableArray arrayWithCapacity:10];
  
  for (int i=0; i&lt;9; i++){
      [k addObject: @"blank"];
  }
  [k addObject: nil]; //&lt;-- NSInvalidArgumentException
  </code></pre>
  
  <p>I need to do all this item by item in a loop and then add the "nil".</p>
  
  <p>Thanks</p>
  
  <p>(I am then taking this array and initializing a 2D array.
  The problem is that I can't successfully "replaceObjectAtIndex" with an array without "nil".
  If I build the "k" with "initWithObjects: @"blank", @"blank", @"blank", ... nil" this will work.  However writing 1000 blanks is a little much. So that is the purpose of the loop.)</p>
  
  <p>////// HERE IS THE TRIAL AND ERROR CODE for init and building 2D Matrix for the purpose of reading and storing a matrix from a "CSV file" ////// </p>
  
  <pre><code>///*
  NSMutableArray *ppp = [NSMutableArray arrayWithCapacity:2];
  NSMutableArray *kkk = [NSMutableArray arrayWithCapacity:20];
  
  NSNull *myNull = [NSNull null];
  for (int i=0; i&lt;9; i++) {
      //[kkk addObject: [NSMutableString stringWithFormat: @"%d",i]];
      [kkk addObject: myNull];
  }
  //[kkk addObject: nil];
  
  [ppp addObject:kkk];
  [ppp addObject:kkk];
  //*/
  
  
  /*
  // this is successful --&gt; just uncomment this block and comment out the block above
  [ppp addObject:[[NSMutableArray alloc] initWithObjects:
               @"z1",
               @"z2",
               @"z3",
               @"z4",
               @"z5",
               @"z6",
               @"z0gg",
               @"z0hh",
               @"z0ii",
               @"z0jj",
               nil
               ]];
  
  [ppp addObject:[[NSMutableArray alloc] initWithObjects:
          @"a1",
          @"b2",
          @"c3",
          @"d4",
          @"e5",
          @"f6",
          nil
          ]];
  </code></pre>
  
  <p>*/  </p>
  
  <pre><code>[[ppp objectAtIndex:0] replaceObjectAtIndex:1 withObject:@"HOTDOG"];
  [[ppp objectAtIndex:1] replaceObjectAtIndex:1 withObject:@"HOHO"];
  // HOHO will replace HOTDOG as well for the code not using "nil"
  </code></pre>