Objective-C NSMutableDictionary消失了

use*_*313 1 iphone memory-management objective-c nsmutablearray nsmutabledictionary

我有NSMutableDictionary的问题,其中值不会出现.我的代码中的代码片段如下所示:

//数据进入哈希然后进入数组

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);

 }
Run Code Online (Sandbox Code Playgroud)

所以问题是只打印了第二个地址,813和我无法弄清楚原因.有人可以提供任何帮助吗?

Lau*_*ble 5

这是一个错字.您始终为Address1字典分配值.