I am having trouble populating an array of objects (employee names) from a group of NSDictionaries (each one representing an individual employee) which are inside another NSDictionary *dictionary (personnel). The key for each sub Dictionary is an employee ID.
I might well be coming at this from a completely wrong direction, i am very much a newbie but from what i have read it should be something like this , i have managed to get as far as a pName (employee name) from each sub Dictionary, all be it fleetingly. I just can't get the pNames added into MutableArray *names.
any help or guidance would be greatly appreciated ...
int i, count;
id key, value;
keys = [dictionary allKeys];
count = [keys count];
for (i = 0; i < count; i++)
{
key = [keys objectAtIndex: i];
value = [dictionary objectForKey: key];
NSLog (@"value:%@", value);
NSString *pName = [value objectForKey:@"personName"];
NSLog (@"pName:%@", pName);// the debugger shows the correct pName with each loop
[names addObject:pName];// this is wrong and i don't know why
}
NSLog (@"names:%@", names);// in the debugger names (null)