Objective-C NSMutableDictionary Disappearing
Posted
by blackmage
on Stack Overflow
See other posts from Stack Overflow
or by blackmage
Published on 2010-03-14T09:00:03Z
Indexed on
2010/03/14
9:05 UTC
Read the original article
Hit count: 475
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?
© Stack Overflow or respective owner