0

I use Parse for my backend data. Here, I saved an array of dictionaries to then query into my app and load into my tableview.

Here is my array saved in Parse:

enter image description here

When I query it in the viewDidLoad I set my empty array (self.dealListArray) equal to the array on Parse.

Here is what it looks like:

enter image description here

The first NSLog() outputs the entire array from Parse perfectly. But the second NSLog outside of the brackets output NULL.

The table view will not load up because my array is NULL. How can I keep the information from the query so that I can fill it with my table view?

Thank you, any help is much appreciated

2
  • Because it's async. [yourTableView reloadData] after the self.dealListArray = [resMenu objectForKey:@"Deals"]; possibly calling it in mainQueue (since it's related to UI). Commented Oct 13, 2015 at 16:00
  • You can build out the querying and updating mechanisms yourself or you can use the Parse provided PFQueryTableViewController in the ParseUI framework. It automatically takes care of showing an activity indicator, refreshing the table with the fetched data when complete, pagination, and tons of other convenience methods Commented Oct 13, 2015 at 18:07

1 Answer 1

2

You have no real guarantee when the block is called. So it's probably best that you wait until the data is loaded and meanwhile to have a UIActivityIndicatorView or something similar to indicate that something is being loaded.

Also, when the block does get called and you change the value of dealListArray you would have to reload the tableview's data.

like this...

self.dealListArray = [resMenu objectForKey@"Deals"];
NSLog(@"%@", self.dealListArray];

[self.tableView reloadData];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.