I currently have a ViewController
with a TableView
inside it called SelectedListItemsViewController
. This ViewController
's TableView
is populated by a custom cell class called SelectedListItemsTableViewCell
.
I have an array of Realm Model Objects called selectedListItems
, each of which has several properties. The SelectedListItemsTableViewCell
populates the TableView
with the listItem
property of that indexPath.row
's object, and each row has a UIStepper
with a UILabel
next to it that (as of now) shows UIStepper.value
for each row. Ideally, the label will reflect the listItemWeight
property of each row, and change it when incrementing or decrementing that row.
This is my custom cell:
class SelectedListItemsTableViewCell: UITableViewCell {
@IBOutlet var selectedListItemLabel: UILabel!
@IBOutlet weak var listItemWeightLabel: UILabel!
@IBOutlet weak var stepperControl: UIStepper!
@IBAction func stepperValueChanged(sender: UIStepper) {
listItemWeightLabel.text = Int(sender.value).description
}
}
And in my ViewController
's cellForRowAtIndexPath
, I've configured the cell like so:
// Configure the cell...
cell.selectedListItemLabel.text = selectedListItems[indexPath.row].listItem
cell.listItemWeightLabel.text = "\(selectedListItems[indexPath.row].listItemWeight)"
Which perfectly loads the listItem
property, and the listItemWeight
property shows up correctly, but as soon as I increment or decrement on the UIStepper
it gets messed up.
How do I properly link my UILabel and UIStepper to the [indexPath.row].listItemWeight
?