I'm having difficulty trying to add a UIBarButtonItem
with title "Next(#)" where # is a dynamic counter that counts the number of cells selected in the table view as the user is selecting them. The array that tracks the cell selections is built and working properly however the count isn't getting updated; print lines in the console work as expected. My intent later is to only show the "(#)" when the count is greater than zero but right now I'm focused on just getting the count to update after each cell gets selected/deselected.
override func viewWillAppear(_ animated: Bool) {
let barButtonCounter = "(\(invitedContacts.count))"
let barButtonItemText = "Next\(barButtonCounter)"
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "\(barButtonItemText)", style: .done, target: self, action: nil)
}
This is the closest SO thread I could find but from what I can tell it's not exactly doing what I want, at least visual design-wise but maybe totally and is written in Obj-C which I don't fully comprehend as I'm new to swift. My preference would be to build this natively without importing a library.