title: Xcode Parse Query button Delete text and photo from a cell
body: <p>each cell displays the according comments and photo of the user logged-on. They are loaded with parse.</p>
  
  <p><a href="https://i.stack.imgur.com/zU39h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zU39h.png" alt="enter image description here"></a></p>
  
  <p>Now you want to Löschen the button deletes the photo and the comments.</p>
  
  <p>Unfortunately this does not work. Wen I click on the button nothing happens</p>
  
  <p>Unfortunately I understand little of swift and can't get on the solution</p>
  
  <p>The query works, and the app displays the photos and Commons.The query and post code:</p>
  
  <pre><code>override func viewDidLoad() {
  super.viewDidLoad()
  super.viewDidLoad()
  let query = PFQuery(className: "Post")
  
  query.whereKey("username", equalTo: PFUser.current()?.username)
  query.findObjectsInBackground(block: { (object, error) in
  
      if let posts = object {
          for post in posts{
              print(posts)
  
              self.comments.append(post["message"] as! String)
              self.imageFile.append(post["imageFile"] as! PFFile)
              self.tableView.reloadData()
          }
  
  
          DispatchQueue.main.async {
              self.tableView.reloadData()
  
          }
      }
  })
  </code></pre>
  
  <p>}</p>
  
  <p>And here of the "delete"function code that I have tried:</p>
  
  <pre><code>   @IBAction func remove(_ sender: Any) {
      print("Entered remove")
      let query = PFQuery(className: "Post")
      query.whereKey("username", equalTo: PFUser.current()?.username)
      query.findObjectsInBackground(block: { (object, error) in
  
          if let posts = object {
              print(posts)
              for post in posts{
                  print(posts)
  
                  if let message = post["message"] as? String, let image = post["imageFile"] as? PFFile {
                      print("message and image read", message, image)
                      if let messageIndex = self.comments.index(of: message), let imageIndex = self.imageFile.index(of:image) {
                          self.comments.remove(at: messageIndex)
                          self.imageFile.remove(at: imageIndex)
  
                      }
                  }
  
                  self.tableView.reloadData()
  
              }
  
              DispatchQueue.main.async {
                  self.tableView.reloadData()
              }
          }
      })
  }
  </code></pre>
  
  <p>The output:</p>
  
  <p><a href="https://i.stack.imgur.com/PgK6z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PgK6z.png" alt="enter image description here"></a></p>
  
  <p>I don't get an error message and nothing is deleted.
  Thank you for your help</p>