Guest User

Untitled

a guest
Oct 16th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. struct Records {
  2.  
  3. let title: String
  4. let source: String
  5. var length: String
  6. let recordUrl: String
  7. let username: String
  8.  
  9. init(dictionary: [String: Any]) {
  10. self.title = dictionary["title"] as? String ?? ""
  11. self.source = dictionary["source"] as? String ?? ""
  12. self.length = dictionary["length"] as? String ?? ""
  13. self.recordUrl = dictionary["recordUrl"] as? String ?? ""
  14. self.username = dictionary["username"] as? String ?? ""
  15. }
  16. }
  17.  
  18. var records = [Records]()
  19.  
  20. func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
  21. guard let uid = Auth.auth().currentUser?.uid else { return }
  22. if (editingStyle == .delete) {
  23. records.remove(at: indexPath.item)
  24. tableView.deleteRows(at: [indexPath], with: .fade)
  25. Database.database().reference().child("users").child(uid).child("records").removeValue()
  26. }
  27. }
Add Comment
Please, Sign In to add comment