what are the initial values in cells (from FRC ?)
My FRC has a custom type called Currency. Currency is a CoreData entity which has attributes: shortName ("USD"), fullName ("American Dollar"), isPickedForConverterScreen (Bool, true), currentValue (Double: 75,44), and so on for other currencies.
My tableView shows the Currency object only when isPickedForConverterScreen == true. tableView cell have 2 labels: for displaying shortName and fullName and a textField. Here is how I define it:
let cell = tableView.dequeueReusableCell(withIdentifier: "converterCell", for: indexPath) as! ConverterTableViewCell
let currency = fetchedResultsController.object(at: indexPath)
cell.shortName.text = currency.shortName
cell.fullName.text = currency.fullName
return cell
}
You type something in a cell
let's assume I have 2 cells in my tableView: USD, RUB.
I click on USD cell - type number - RUB cell recalculate its textField.text as: number I typed in USD cell x RUB.CurrentValue. For example I typed 2, then 2 x 75,44 = 150,88 to display in RUB cell. Calculation should be performed live, not when I end editing USD cell
What do you then get in all cells ?
The thing is I need to perform a calculation for all cells based on number I typed in active cell x currentValue number stored for each Currency object. And I should be able to pick another cell with currency and calculate all other currencies based on value I typed + their currentValue
So am I understood correct that my dataSource is the array of Currencies which I can receive as:
let array: [Currencies] = fetchedResultsController.fetchedObjects
I don't define it anywhere in my VC for now. Only when defying cell in cellForRow:
let currency = fetchedResultsController.object(at: indexPath)
Topic:
UI Frameworks
SubTopic:
UIKit
Tags: