Tim
Tim

Reputation: 113

iOS How to load a table after data is loaded?

In my iOS Project I want to generate a table with data from a json file, the problem is that the table is created before the data is loaded!

How can I generate the table after the data is loaded?

Upvotes: 0

Views: 135

Answers (2)

Dave
Dave

Reputation: 7717

  1. In your viewDidLoad method, you get the data as an asynchronous process in the background.
  2. When the data arrives, parse it out and populate your "model".
  3. Once model is populated, use notification manager to send a notice to anyone interested in that fresh data.
  4. Catch the notice in your tableview and call [self.tableView reloadData];

That's the gist of it. Best of luck!

Upvotes: 1

user529758
user529758

Reputation:

When the loading of the data is completed, call [tableView reloadData] on the main thread.

Upvotes: 4

Related Questions