Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "location" : {
- "-LY55OLlInZ0HLepGZWp" : {
- "Activity" : "Legs",
- "Description" : "Anainssnsj skaknHsiansnAhah",
- "Difficulty" : "Beginner",
- "Lat" : "",
- "Long" : "",
- "Rating" : "3",
- "Title" : "Busan",
- "id" : "-LY55OLjAA3Cbcvaf8SG"
- },
- "-LY55SN53euLPN9UxoM5" : {
- "Activity" : "Board",
- "Description" : "Stktwks",
- "Difficulty" : "Beginner",
- "Lat" : "lat:-35.14202623881991",
- "Long" : "long:138.54526039212942",
- "Rating" : "3",
- "Title" : "Jettei",
- "id" : "-LY55SN40TARVvysV8fi"
- },
- },
- func saveLocationInformation() {
- let key = refLocation.childByAutoId().key
- guard let title = locationTitle.text else {return}
- guard let location = geoCoordinate.text else {return}
- guard let long = geoLong.text else {return}
- guard let description = descriptionText.text else {return}
- guard let rating = flameNumber.text else {return}
- guard let difficulty = difficultyRating.text else {return}
- guard let activity = activityLabel.text else {return}
- let lTitle = [
- "id": key,
- "Title": title,
- "Activity": activity,
- "Lat": location,
- "Long": long,
- "Description": description,
- "Rating": rating,
- "Difficulty": difficulty,
- ] as [String:Any]
- let lID = [
- "id": key,
- ] as [String:Any]
- refLocation.childByAutoId().setValue(lTitle)
- }
- import UIKit
- import Firebase
- class TableViewControllerVC: UITableViewController {
- var locationData = [locationSearch]()
- var ref: DatabaseReference!
- var dataHandle: DatabaseHandle?
- override func viewDidLoad() {
- super.viewDidLoad()
- loadInfo()
- }
- override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return locationData.count
- }
- override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = tableView.dequeueReusableCell(withIdentifier: "TabViewCell", for: indexPath)
- return cell
- }
- func loadInfo() {
- ref = Database.database().reference()
- ref.child("location").observe(.value) { (snapshot: DataSnapshot) in
- if let dict = snapshot.value as? [String: AnyObject] {
- //
- let titleT = dict["Title"]
- // let activityA = dict["Activity"] as! String
- // let loc = locationSearch(titleText: titleT, activityText: activityA)
- // self.locationData.append(loc)
- print(titleT)
- self.tableView.reloadData()
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment