Please help me with filling table view cells with data from a dictionary. For instance, I have cell like so:
and for filling it with data I\'ve started with
By using this:
var valueArray: [Int] = []
var currencyArray: [String] = []
override func viewDidLoad() {
super.viewDidLoad()
for (key, value) in currencies! {
print("key is - \(key) and value is - \(value)")
currencyArray.append(key)
valueArray.append(value)
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CurrencyCell", for: indexPath) as! CurrencyCell
//retrieve the key and value
let value = valueArray[indexPath.row]
let key = currencyArray[indexPath.row]
//next use the value and key for what you need them
return cell
}