When it comes to an item on list in swift, access directly on the data itself

less than 1 minute read

Published:

say ur UIController implements some protocol like UITableViewDelegate, UITableViewDataSource

just don’t access the value from the view element, go to the variable you want to change

override this one

public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
 //do something on your element
self.itemList[indexPath.section].isExpanded = !self.itemList[indexPath.section].isExpand


}

as that function gets called whenever some tap gesture is executed.