Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // method to run when table view cell is tapped
- func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
- print("You tapped cell number (indexPath.row).")
- if let cell = tableView.cellForRow(at: indexPath as IndexPath) {
- if cell.accessoryType == .checkmark {
- cell.accessoryType = .none
- } else {
- cell.accessoryType = .checkmark
- let item = users[indexPath.row]
- print(item) // here printing cell selection data
- }
- }
- }
- You tapped cell number 1.
- User(userId: "121”, active: 1, name: example_table.Name(firstname: "jack", lastname: "m"))
- You tapped cell number 2.
- User(userId: "122”, active: 1, name: example_table.Name(firstname: “rose”, lastname: “h”))
- You tapped cell number 3.
- User(userId: "123”, active: 1, name: example_table.Name(firstname: “makj”, lastname: “i”))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement