I'm using Parse.com on Swift, but TableView update doesn't work.

Asked 2 months ago, Updated 2 months ago, 4 views

I am creating a program to display textField characters in TableView using Parse, MBaaS on Swift, but the part that I pull TableView to update is not working.

override func viewDidLoad(){

    Retrieving data from //parse
    // Configure DataSource settings.

    // Configure Delete.

    // Pull to update


Retrieving data from //parse
    varquery —PFQuery=PFQuery (className: "Comment")
    query.findObjectsInBackgroundWithBlock{(objects:[AnyObject]!, error:NSError!) ->Void in
            // error handling

        // Put parse data in PFObject comments
        for object in objects {


// Pull to update function
func pullrefresh(){
    self.refreshControl.attributedTitle=NSAttributedString(string: "↓pull")
    self.refreshControl.addTarget(self, action: "refresh:", forControlEvents:UICControlEvents.ValueChanged)
// How to get data for updates
func refresh (sender: AnyObject)
    Finish //refresh

I wrote a program like this, but when I pull it and update it, the same content appears double.
How do I update only the text that is already displayed on the screen without duplication?
I look forward to hearing from you.

ios swift xcode parse.com

2022-09-30 14:30

1 Answers

I've never used Parse, but I'll write down what I noticed.

As PFQuery does not seem to be specifically narrowed down, I always get everything from query.findObjectsInBackgroundWithBlock.I added it to self.comments that already contain data, so it seems to have been added in duplicate.

Therefore, if possible, PFQuery will narrow it down by date, or if not, replace self.comments with the retrieved array


I think it's better to do so.

Also, query.findObjectsInBackgroundWithBlock seems to be handled in the background, but which thread is the callback called?It would be nice if the main thread is always referred to as a specific thread, but if not, there is a possibility of simultaneous execution failures.Also, tableView.reloadData must be run on the main thread.

2022-09-30 14:30

If you have any answers or tips

© 2022 OneMinuteCode. All rights reserved.