Reputation: 1110
I have table view with multiple different cells, and one of the cells depends on property of another one. I.e. I have FirstCell, which has dynamic property count
, and I have SecondCell, which contains several UITextFields. I want the number of these UITextFields to match the count
property. How can I get count
property from FirstCell considering that this property can be changed?
I.g. FirstCell contains count = 3
, SecondCell shows three UITextFields. Property count
changes to value 4
and another one UITextField appears in SecondCell.
Upvotes: 0
Views: 170
Reputation: 52538
The value of count should be in your data model. You add an observer, or put code into the setter, so when the value of count is changed, the two cells depending on it (the one displaying count, and the one showing the text fields) are both reloaded; that's reloadCellAtIndexPaths or something like that from memory.
Obviously the code that loads cells must be written correctly, and code changing count in the first cell must change the model property.
Upvotes: 1
Reputation: 14063
Thinks like this should be managed by the UI(Table)ViewController
. The view controller should be notified when the text field changes (for example using target-action) and then update the data source and reload the relevant cells.
Upvotes: 0