can someone explain to me why [tweets count]; is equal to 1 please? the finalDict atm only has one dictionary, but arrayForLetter has 6 and in each of them some values. how do i get all 6 dictionaries from arrayForLetter ?
NSEnumerator *enumerator = [finalDict keyEnumerator];
id key;
while ((key = [enumerator nextObject])) {
NSDictionary *arrayForLetter = [finalDict objectForKey:key];
NSLog(@"arrayForLetter %@",arrayForLetter);
NSEnumerator *myEnumerator = [arrayForLetter keyEnumerator];
id myKey;
while ((myKey = [myEnumerator nextObject])) {
statuses=[[arrayResults alloc] initWithAppDictionary:arrayForLetter andAppID:myKey];
tweets = [[NSMutableArray alloc] init] ;
[tweets addObject:statuses];
[countryList reloadData];
//NSLog(@"%@ : %@", key, [finalDict objectForKey:key]);
}
}
The reason is obvious.. within the while loop you are re-allocating the tweets array and then adding an object. To get count of 6 you need to alloc – init the tweets array before the while loop !