ios - Runtime error when pressing like button -


i want save number of likes , people liked in posts table under key of post

invalid update: invalid number of rows in section 0. number of rows contained in existing section after update (1) must equal number of rows contained in section before update (1), plus or minus number of rows inserted or deleted section (1 inserted, 0 deleted) , plus or minus number of rows moved or out of section (0 moved in, 0 moved out). here image

 @ibaction func didtaplike(_ sender: any) {      print("like tappppppppped")     self.loggedinuser = auth.auth().currentuser     let key =  ref.child("posts").childbyautoid().key      ref.child("posts").child(self.loggedinuser!.uid).observesingleevent(of: .value, with: { (snapshot) in         if let post = snapshot.value as? [string : anyobject] {             print(post)           let updatelikes :[string:any] = ["userswholiked/\(key)" : auth.auth().currentuser!.uid]              self.ref.child("posts").child(self.loggedinuser!.uid).updatechildvalues(updatelikes)           }       })     } 

this in home view controller , button in tableview cell

       override func viewdidload() {            super.viewdidload()      self.ac.startanimating()      self.loggedinuser = auth.auth().currentuser      self.databaseref.child("users").child(self.loggedinuser!.uid).observesingleevent(of: .value) {         (snapshot:datasnapshot) in          let  snao = snapshot.value as! [string:anyobject]         if (snao["pc"] != nil) {         self.x = snao["pc"] as! string         }          if let t    = snao anyobject?         {             self.loggedinuserdata = t         }          //  print(self.loggedinuserdata)          self.databaseref.child("posts").child(self.loggedinuser!.uid).observe(.childadded, with: {( snap: datasnapshot) in              let snapp = snap.value as! [string:anyobject]             if let x = snapp["text "] as! string? {                 self.posts.insert(x, at: 0)              }              self.feeds.insertrows(at: [indexpath(row : 0 ,section : 0)], with: uitableviewrowanimation.automatic)             self.feeds.reloaddata()              self.ac.stopanimating()         }          )}   } 


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -