ios - How do I add a google maps marker when Pressing a button? -


is possible fetch child nodes parent in firebase db?

trying this: this

i want posts @ same time.

it fetches videos current users videos. want fetch users videos @ same time. here's code more understanding of i'm doing:

fileprivate func fetchallpost() {     fetchposts()     fetchallpostsfromuserids() }  fileprivate func fetchallpostsfromuserids() {     guard let uid = firauth.auth()?.currentuser?.uid else { return }     firdatabase.database().reference().child("posts").child(uid).observesingleevent(of: .value, with: { (snapshot) in          guard let useridsdictionary = snapshot.value as? [string: any] else { return }         useridsdictionary.foreach({ (key,  value) in             firdatabase.fetchuserwithuid(uid: key, completion: { (user) in                 self.fetchpostswithuser(user: user)             })         })     }) { (err) in         print("failed fetch following users ids:", err)     } }  var posts = [post]() fileprivate func fetchposts() {     guard let currentuserid = firauth.auth()?.currentuser?.uid else { return }     firdatabase.fetchuserwithuid(uid: currentuserid) { (user) in         self.fetchpostswithuser(user: user)     } }  fileprivate func fetchpostswithuser(user: user) {     let ref = firdatabase.database().reference().child("posts/\(user.uid)/")      ref.observesingleevent(of: .value, with: { (snapshot) in          self.collectionview?.refreshcontrol?.endrefreshing()          guard let dictionaries = snapshot.value as? [string: any] else { return }         dictionaries.foreach({ (key,value) in              guard let dictionary = value as? [string: any] else { return }             var  post = post(user: user, dictionary: dictionary)             post.id = key             guard let uid = firauth.auth()?.currentuser?.uid else { return }             firdatabase.database().reference().child("likes").child(key).child(uid).observe(.value, with: { (snapshot) in                 if let value = snapshot.value as? int, value == 1 {                     post.hasliked = true                 } else {                     post.hasliked = false                 }                 self.posts.append(post)                  self.posts.sort(by: { (p1, p2) -> bool in                     return p1.creationdate.compare(p2.creationdate) == .ordereddescending                 })                 self.collectionview?.reloaddata()              }, withcancel: { (err) in                 print("failed fetch info post")             })             print(self.posts)         })     }) { (error) in         print("failed fetch posts", error)     }   } 

i don't know swift, fetch firdatabase.database().reference().child("posts") , iterate on children.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -