Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. // method to run when table view cell is tapped
  2. func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  3. print("You tapped cell number (indexPath.row).")
  4.  
  5. if let cell = tableView.cellForRow(at: indexPath as IndexPath) {
  6. if cell.accessoryType == .checkmark {
  7. cell.accessoryType = .none
  8. } else {
  9. cell.accessoryType = .checkmark
  10. let item = users[indexPath.row]
  11. print(item) // here printing cell selection data
  12. }
  13. }
  14. }
  15.  
  16. You tapped cell number 1.
  17. User(userId: "121”, active: 1, name: example_table.Name(firstname: "jack", lastname: "m"))
  18. You tapped cell number 2.
  19. User(userId: "122”, active: 1, name: example_table.Name(firstname: “rose”, lastname: “h”))
  20. You tapped cell number 3.
  21. User(userId: "123”, active: 1, name: example_table.Name(firstname: “makj”, lastname: “i”))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement