daily pastebin goal
53%
SHARE
TWEET

Untitled

a guest Feb 19th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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”))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top