I am starting quickly, and I am trying to understand the concept of dictionaries.
I have two NSDictionary that contain the same keys:
var currencyname: NSDictionary = [
"CNY": "Chinese Yuan",
"PLN": "Polish Zloty"
]
var rawrates NSDictionary = [
"CNY": "1.34",
"PLN": "1.456"
]
I try to combine them to get only one dictionary, for example:
["CNY": "Chinese Yuan","1.34"]
["PLN": "Polish Zloty","1.456"]
I guess my first question is, which variable should I put the output? Can i use NSDictionary? Due to the fact that I was reading the documentation, I realized that NSDictionaries work on Key / Values pairs. Can I put two words in a dictionary?
My second question: how should I combine these two dictionaries, I tried to use the code below without much success
for (currency, rawrate) in rawrates {
for (currencyid, name) in currencyname{
if currency == currencyid {
rawrates.append(name as String)
}
}
}
source
share