0

I'm developing an iPhone application where the data comes from a webservice that returns a json file. I'm using the following command in the viewDidLoad of the UITableViewController where I want to bind the data:

    responseData = [[NSMutableData data] retain];


NSURLRequest *request = [NSURLRequest requestWithURL:
                         [NSURL URLWithString:@"webservice url"]];

[[NSURLConnection alloc] initWithRequest:request delegate:self];

and then I get the data from the json result into a NSDictionary in the connectionDidFinishedLodading Delegate.

The problem is that the numberOfRowsInSection delegate from UITableView executes before the connection finishes downloading data, which makes my table view with zero rows and doesn't show anything.

What am I doing wrong? Did I misunderstand the concept of the viewDidLoad and should be loading this data elsewhere?

1 Answer 1

2

Call reloadData on the tableView when you are done processing the data.

[self.tableView reloadData];

This triggers all UITableViewDatasource methods anew.

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.