Jeba Prince
Jeba Prince

Reputation: 1671

how to dynamically update table view in IOS?

i have a table and custom cells created dynamically, i have a http asyn call which gets me JSON data, now i need to update the table cells with the data received...

Upvotes: 14

Views: 21874

Answers (4)

Breedly
Breedly

Reputation: 14226

Adding a bit more context using swift. If you are trying to do this from a class that implements UITableViewController it will have a property tableView upon which you can call tableView.reloadData().

For example:

import UIKit

class TableViewController implements UITableViewController {
  private func changeData() -> Void {
   //... changes data
   tableView.reloadData()
  }
}

Source: UITableViewController

Upvotes: 0

user2168844
user2168844

Reputation: 73

call the table reloadData instance method . where ever you want to update the data of table.

Upvotes: 0

stack2012
stack2012

Reputation: 2186

Have to NSNotification, one in the loadview and another one in the

- (void)connectionDidFinishLoading:(NSURLConnection *)connection  

delegate method , like this:

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateTable) name:@"downloadCompleted" object:nil];

The above one in loadview method and the following one in the delegate

[[NSNotificationCenter defaultCenter] postNotificationName:@"downloadCompleted" object:nil];

the updateTable method will be called once data is obtained from JSON parsing. You can call the reloadData method of the tableview in this method to fill the tableview with obtained values.... Hope this helps.. Cheers...Happy coding..

Upvotes: 7

Nathanial Woolls
Nathanial Woolls

Reputation: 5291

Call:

[self.tableView reloadData];

Upvotes: 55

Related Questions