title: How to addObject of NSMutableDictionary to NSMutableArray in a loop
body: <p>I'm having difficulty to add a data structure to an array to create an array of dictionaries from a loop. I just knew that addObject in NSMutableArray only add pointer to it. I would like to know how to achieve my goal.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>NSMutableDictionary *woRows = [[NSMutableDictionary alloc] init];
  NSMutableArray *workOrders = [[NSMutableArray alloc] init];
  while ([theScanner isAtEnd] == NO)
  {
      if ([theScanner scanUpToCharactersFromSet:usSet intoString:&amp;tempCol1] &amp;&amp;
          [theScanner scanString:@"{US}" intoString:NULL] &amp;&amp;
          [theScanner scanUpToCharactersFromSet:usSet intoString:&amp;tempCol2] &amp;&amp;
          [theScanner scanString:@"{US}" intoString:NULL] &amp;&amp;
          [theScanner scanUpToCharactersFromSet:usSet intoString:&amp;tempCol3]&amp;&amp;
          [theScanner scanString:@"{RS}" intoString:NULL])
      {
          [woRows  setValue:tempCol1 forKey:@"hours"];
          [woRows setValue:tempCol2 forKey:@"colMain"];
          [woRows setValue:tempCol3 forKey:@"colAddtl"];
  
          [workOrders addObject:woRows];
          [woRows release];
      }
  }
  [tmpString release];
  [jobs addObject:workOrders];
  [workOrders release];
  </code></pre>
  
  <p>from the code above, the array workOrders will have duplicates of last objects added only. I stuck here not able to progress to display the correct data.</p>
  
  <p>Any help will be appreciated.</p>
  
  <p>Thanks</p>