Guest User

Untitled

a guest
Feb 18th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. {
  2. "location" : {
  3. "-LY55OLlInZ0HLepGZWp" : {
  4. "Activity" : "Legs",
  5. "Description" : "Anainssnsj skaknHsiansnAhah",
  6. "Difficulty" : "Beginner",
  7. "Lat" : "",
  8. "Long" : "",
  9. "Rating" : "3",
  10. "Title" : "Busan",
  11. "id" : "-LY55OLjAA3Cbcvaf8SG"
  12. },
  13. "-LY55SN53euLPN9UxoM5" : {
  14. "Activity" : "Board",
  15. "Description" : "Stktwks",
  16. "Difficulty" : "Beginner",
  17. "Lat" : "lat:-35.14202623881991",
  18. "Long" : "long:138.54526039212942",
  19. "Rating" : "3",
  20. "Title" : "Jettei",
  21. "id" : "-LY55SN40TARVvysV8fi"
  22. },
  23. },
  24.  
  25. func saveLocationInformation() {
  26. let key = refLocation.childByAutoId().key
  27.  
  28. guard let title = locationTitle.text else {return}
  29. guard let location = geoCoordinate.text else {return}
  30. guard let long = geoLong.text else {return}
  31. guard let description = descriptionText.text else {return}
  32. guard let rating = flameNumber.text else {return}
  33. guard let difficulty = difficultyRating.text else {return}
  34. guard let activity = activityLabel.text else {return}
  35.  
  36.  
  37. let lTitle = [
  38. "id": key,
  39. "Title": title,
  40. "Activity": activity,
  41. "Lat": location,
  42. "Long": long,
  43. "Description": description,
  44. "Rating": rating,
  45. "Difficulty": difficulty,
  46. ] as [String:Any]
  47. let lID = [
  48. "id": key,
  49. ] as [String:Any]
  50.  
  51. refLocation.childByAutoId().setValue(lTitle)
  52.  
  53. }
  54.  
  55. import UIKit
  56. import Firebase
  57. class TableViewControllerVC: UITableViewController {
  58.  
  59.  
  60. var locationData = [locationSearch]()
  61.  
  62. var ref: DatabaseReference!
  63. var dataHandle: DatabaseHandle?
  64.  
  65.  
  66.  
  67.  
  68. override func viewDidLoad() {
  69.  
  70. super.viewDidLoad()
  71.  
  72. loadInfo()
  73. }
  74.  
  75. override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  76. return locationData.count
  77. }
  78.  
  79.  
  80.  
  81. override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  82. let cell = tableView.dequeueReusableCell(withIdentifier: "TabViewCell", for: indexPath)
  83.  
  84.  
  85.  
  86. return cell
  87. }
  88.  
  89.  
  90. func loadInfo() {
  91. ref = Database.database().reference()
  92. ref.child("location").observe(.value) { (snapshot: DataSnapshot) in
  93. if let dict = snapshot.value as? [String: AnyObject] {
  94. //
  95. let titleT = dict["Title"]
  96. // let activityA = dict["Activity"] as! String
  97. // let loc = locationSearch(titleText: titleT, activityText: activityA)
  98. // self.locationData.append(loc)
  99.  
  100. print(titleT)
  101. self.tableView.reloadData()
  102. }
  103. }
  104.  
  105. }
  106.  
  107.  
  108.  
  109.  
  110. }
Add Comment
Please, Sign In to add comment