0

I have JSON web-service and my task is to parse the web service and store the data into UITableview.

I am parsing the web service using NSURLConnection methods.

After parsing the web-service i got the response what I wanted .

But the issue is that my UIViewController is calling UITableView Delegate and Datasource methods first and then it calls web-service so my UITableView doesn't get any response.

Even though I call the web-service first it calls all the UITableView Delegate and Datasource methods first and then web-service so my table view doesn't get any response.

After calling the web-service i get perfect response.

So if somebody knows any solution please help me. Thank you.

Ashish Kakkad
  • 23,586
  • 12
  • 103
  • 136
Pradumna Patil
  • 2,180
  • 3
  • 17
  • 46

3 Answers3

1

After you get your response and populate dataSource just call

[self.tableView reloadData];
kedzia
  • 295
  • 2
  • 12
1

The other answers in this thread should solve your problem.

However, if you find that [self.tableView reloadData] isn't refreshing the data in your UITableView, check out my suggestion on this thread:

Fails to call delegate/datasource methods in UITableView implementation

I'm not sure if this is a quirk with iOS 8, but I've had a few occassions where just setting the table's dataSource and delegate in the code hasn't been enough.

Community
  • 1
  • 1
Mike Gledhill
  • 27,846
  • 7
  • 149
  • 159
  • Then, I'm not sure. You could try copying the code I put in my XCode tutorial, and see if that points you in the right direction: http://www.mikesknowledgebase.com/pages/Services/WebServices-Page6.htm – Mike Gledhill Feb 23 '15 at 13:40
  • Thank you but it is not working for me.My problem is not in calling delegate or datasource method of uitableview .It works fine.But the problem is it should get called after webservice calling so my table view will get some response which is not happening. All the methods written on that viewcontroller are get called and then at last my webservice gets called so table view is not getting any response. This is the issue – Pradumna Patil Feb 23 '15 at 13:43
  • Thanks Mike the demo helped me. – Pradumna Patil Feb 24 '15 at 05:13
0

Just set the data-source and delegate of table view in the delegate of the web-service delegate or where you get the response and reload the table view.

BADRI
  • 643
  • 8
  • 26