I try to insert dictionary into dictionary by passing dictionary as argument into method. I have a one dictionary with keys 0,1,2,...,6 which consist of dictionaries and i try to fetch dictionary with key 0, in new dictionary but new dictionary is nil.
dictionaryWithWeekDays consist of something like this:
0 = {
clouds = 0;
deg = 239;
dt = 1475175600;
humidity = 76;
pressure = "993.71";
speed = "3.24";
temp = {
day = "70.09";
eve = "74.73";
max = "76.64";
min = "51.53";
morn = "54.66";
night = "51.53";
};
weather = (
{
description = "light rain";
icon = 10d;
id = 500;
main = Rain;
}
);
};
1 = {
clouds = 12;
deg = 337;
dt = 1475607600;
humidity = 0;
pressure = "1012.86";
speed = "3.89";
temp = {
day = "59.59";
eve = "64.56";
max = "64.56";
min = "49.64";
morn = "49.64";
night = "54.32";
};
weather = (
{
description = "light rain";
icon = 10d;
id = 500;
main = Rain;
}
);
};
I have a for loop because want to pass all keys in method. and i just call my method into loop like this:
for (int i = 0; i <= 6; i++) {
NSString *key = [NSString stringWithFormat:@"%i", i];
[self addValuesToArrayWithTemp:dictionaryWithWeekDays key:key index:i];
}
And here is my addValuesToArrayWithTemp :
-(void) addValuesToArrayWithTemp:(NSDictionary *)inputDic key:(NSString *)key index:(int)ind {
NSDictionary *currentDic = [inputDic objectForKey:key];
NSLog(@"currentDic = %@", currentDic);
NSLog(@"key = %@", key);
...
...
}
(NSDictionary *)inputDic
- is ok it consist all what i pass before, key also alright have @"0" value. but the currentDic is nil. Why?? Maybe i misunderstand something. Thanks for help!
I'm assuming your printout of dictionaryWithWeekDays is from the debugger. I believe that your keys in dictionaryWithWeekDays are not strings, if they were, the listing should show "0" = instead of 0 =
You want to check what's actually the type of the key value in dictionaryWithWeekDays.