Title: PFQueryTableViewController reload table when back btn pressed
Tags: ios;objective-c;parse-platform
Question: Using Parse, after I'm logged in I am presented PFQueryTableViewController that displays a list of tasks and another detail view controller that allows me to edit the task detail and segue back. The issue right now is that the PFQueryTableViewController does not reflect the new changes after I finished editing and popping the task detail view off the stack. However the table view list does get updated when I go back to the login screen(view before the PFQueryTableViewController) and re-enter the table view again. I've tried the following:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.tableView reloadData];
and also
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self loadObjects];
[self.tableView reloadData];
Yet they don't seem to take effect. My guess is that the data is updated after the view is popped off and the table view appears. I'm just wondering if anyone has any insight on this while I'm investigating. Thanks!
Comment: loadObjects is a parse.com method. What i can find out about it: https://www.parse.com/docs/ios/api/Classes/PFQueryTableViewController.html#//api/name/loadObjects

Comment: using the save method provided by parse. https://www.parse.com/docs/ios_guide#objects-saving/iOS
I guess if I can make sure save is completed before loading the table view then the data might refresh properly.

Comment: How are you saving the changes and know when the save is complete?

Comment: Can you post your code for the loadObjects method?


Here is another answer: You can use [self loadObjects] to trigger a refresh for all objects in the PFQueryTableViewController.

Here is another answer: You should make sure the data is saved before popping your view controller.
Use Parse's save method with completion handler.
[request saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (succeeded) {
[self.navigationController popViewControllerAnimated:YES];
Comment for this answer: @MlabTechnologies You can also try setting cache policy to network-only: query.cachePolicy = kPFCachePolicyNetworkOnly;
Comment for this answer: Thanks, but I tried that and it still didn't work.  I have begun using a regular UITableViewController with no issues.

Here is another answer: This answer assumes that you are using Local Datastore and want to see changes made in it be reflected in a PFQueryTableViewController.
Because the ParseUI classes do not implement any form of caching though the local datastore, changes made in the detail view will not appear in the PFQueryTableViewController until the save operation has completed and the tableView has fetched the new items from Parse.
One solution to your problem would be adding a category to the PFQueryTableViewController that modifies how it fetches data to include what is in the Local Datastore as well.

Here is another answer: You could try re-querying the queryForTable method in viewDidAppear (this would naturally use an API request on every view appearance however)
- (void)viewDidAppear:(BOOL)animated {
[self queryForTable];

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 4, 'CommentCount': 4, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2013:00:05/24/13', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<ios><objective-c><parse-platform>', 'Title': 'PFQueryTableViewController reload table when back btn pressed', 'ViewCount': 843, 'id': 16726417, 'user_AboutMe': '<p>User experience designer working on both web and mobile projects.</p>\n', 'user_AccountId': 521319.0, 'user_DisplayName': 'Poyi', 'user_Reputation': 892.0, 'user_Views': 98.0, 'user_id': 1373218.0}}