title: How do I put objects in an NSArray into an NSSet?
body: <p>I have some <code>NSDictionary</code> objects stored in an <code>NSArray</code> called <code>telephoneArray</code>.  I fetch the values for the key <code>number</code> and then replace the <code>NSDictionary</code> I've just read with a new object at the same index in the array.  I then want to put these new objects into an <code>NSSet</code>.  How can this be achieved?  See my unsuccessful attempt below.</p>
  
  <pre><code>    // Add all telephones to this branch
      for (int i=0; i&lt;[telephoneArray count]; i++) {
  
          [newTelephone setBranch:newBranch];
          [newTelephone setNumber:[[telephoneArray objectAtIndex:i] valueForKey:@"number"]];
  
          NSLog(@"%@",[[telephoneArray objectAtIndex:i] valueForKey:@"number"]);
          [telephoneArray replaceObjectAtIndex:i withObject:newTelephone];
          NSLog(@"phone number %i = %@",i,[[telephoneArray objectAtIndex:i] valueForKey:@"number"]);
  
      }
  
      NSSet *telephoneSet = [NSSet setWithArray:telephoneArray];
  
      NSLog(@"telephoneArray=%i",[telephoneArray count]);
      NSLog(@"telephoneSet=%i",[[telephoneSet allObjects] count]);
  </code></pre>
  
  <p>OUTPUT:</p>
  
  <pre><code>2010-03-06 03:06:02.824 AIB[5160:6507] 063 81207
  2010-03-06 03:06:02.824 AIB[5160:6507] phone number 0 = 063 81207
  2010-03-06 03:06:02.825 AIB[5160:6507] 063 81624
  2010-03-06 03:06:02.825 AIB[5160:6507] phone number 1 = 063 81624
  2010-03-06 03:06:02.825 AIB[5160:6507] 063 81714
  2010-03-06 03:06:02.826 AIB[5160:6507] phone number 2 = 063 81714
  2010-03-06 03:06:02.826 AIB[5160:6507] 063 81715
  2010-03-06 03:06:02.826 AIB[5160:6507] phone number 3 = 063 81715
  2010-03-06 03:06:02.826 AIB[5160:6507] telephoneArray=4
  2010-03-06 03:06:02.827 AIB[5160:6507] telephoneSet=1
  </code></pre>
  
  <p>With the code above, telephoneArray can have a count of between 1 and 5 but telephoneSet always has a value of 1.  I assume there's an obvious mistake but I can't see where.</p>