开发者

UITableview datasource methods and retrieving json as the datasource

开发者 https://www.devze.com 2023-04-01 11:53 出处:网络
I\'m using the RestKit library to load json from my REST services, an开发者_如何学运维d then mapping the data to an object.

I'm using the RestKit library to load json from my REST services, an开发者_如何学运维d then mapping the data to an object.

If I apply that retrieved object as the datasource, the tableview datasource methods run before the json is downloaded, which leaves [list count] at 0.

Now, how do I prevent the table from loading or refresh the table when the json is retrieved?


1.) Read your JSON into an array and use that as the data source for your table 2.) If your JSON updates, have some function

-(void)tableDataDidUpdate

that takes in your JSON, throws out the old table data array and replaces it with a new array.

3.) Make sure to call "reloadData"

    [self.tableView reloadData];
0

精彩评论

暂无评论...
验证码 换一张
取 消