Objective-C NSMutableDictionary Disappearing
- by blackmage
I am having this problem with the NSMutableDictionary where the values are not coming up.
Snippets from my code look like this:
//Data into the Hash and then into an array
yellowPages = [[NSMutableArray alloc] init];
 NSMutableDictionary *address1=[[NSMutableDictionary alloc] init];
 [address1 setObject:@"213 Pheasant CT" forKey: @"Street"];
 [address1 setObject:@"NC" forKey: @"State"];
 [address1 setObject:@"Wilmington" forKey: @"City"];
 [address1 setObject:@"28403" forKey: @"Zip"];
 [address1 setObject:@"Residential" forKey: @"Type"];
 [yellowPages addObject:address1];
 NSMutableDictionary *address2=[[NSMutableDictionary alloc] init];
 [address1 setObject:@"812 Pheasant CT" forKey: @"Street"];
 [address1 setObject:@"NC" forKey: @"State"];
 [address1 setObject:@"Wilmington" forKey: @"City"];
 [address1 setObject:@"28403" forKey: @"Zip"];
 [address1 setObject:@"Residential" forKey: @"Type"];
 [yellowPages addObject:address2];
 //Iterate through array pulling the hash and insert into Location Object
 for(int i=0; i<locationCount; i++){
  NSMutableDictionary *anAddress=[theAddresses getYellowPageAddressByIndex:i];
  //Set Data Members
  Location *addressLocation=[[Location alloc] init];
  addressLocation.Street=[anAddress objectForKey:@"Street"];
  locations[i]=addressLocation;
  NSLog(addressLocation.Street);
 }
So the problem is only the second address is printed, the 813 and I can't figure out why. Can anyone offer any help?