title: addObject in NSMutableArray is copied or retained?
body: <p>When you add object into collection, such as <code>NSMutableArray</code>, the object is copied, that is, value semantics, or is retained, that is, reference semantics?</p>
  
  <p>I am confused in the example:</p>
  
  <pre><code>NSMutableString *testStr = [@"test" mutableCopy];
  NSMutableArray *arrayA = [[NSMutableArray alloc] init];
  
  [arrayA addObject:testStr];
  NSLog(@"%@", arrayA);    // output: test
  
  testStr = [@"world" mutableCopy];
  NSLog(@"%@", arrayA);    // output: test
  
  // testStr is copied - value semantics
  
  NSMutableArray *testArr = [@[@1, @2] mutableCopy];
  NSMutableArray *arrarB = [[NSMutableArray alloc] init];
  
  [arrarB addObject:testArr];
  NSLog(@"%@", arrarB);      // output: [1, 2]
  
  [testArr addObject:@3];
  NSLog(@"%@", arrarB);      // output: [1, 2, 3]
  
  // testArr is retained - reference semantics
  </code></pre>
  
  <p>You can see: if the object is a <code>NSMutableString</code>, it looks like the object is copied - you change the object will not affect the object in the array.</p>
  
  <p>However, if the object is a <code>NSMutableArray</code>, when you change the object, the object in the array also be changed - like you retain the object or pass by reference.  </p>
  
  <p>Am I missing something here?
  Thanks.</p>