Hi I have a json string converted unsing the JSON framework into a dictionary and I need to extract its content. How could I iterate to the nested dictionaries? I have alrea
I have tried recursion and hope this could help.
P.S. This will return the first occurrence of the key.
+(id)getValue:(NSDictionary*)aDictionary forKey:(NSString *)aKey {
id finalValue = nil;
for (id key in [aDictionary allKeys]) {
id value = aDictionary[key];
if (value != nil && [key isEqualToString:aKey]) {
finalValue = value;
break;
}
else if ([value isKindOfClass:[NSDictionary class]]) {
finalValue = [[self class] getValue:value forKey:aKey];
}
}
return finalValue;
}