开发者

iPhone ASIHTTPRequest Asyncroneous Extracting Response from the requestFinished Method

I have a response that i have returned from the server as a string that needs setting so i can use it in my viewdidload method....

I need the response to be parsed and then displayed in a table view.... I have done this fine using a synchronous request but async would be better for the UI.

below is the method used to grab the response.

- (void)requestFinished:(ASIHTTPRequest *)request
{
   // Use when fetching text data
   NSString *responseString = [request responseString];
} 

I need to use the data stored in the "responseString" in my viewdidlo开发者_JAVA百科ad method so that the response is parsed and loaded into the table view.


You don't need it in your viewDidLoad. As you've seen, it comes back too late for that.

What you need is to trigger your UITableView to reload itself once you've got your data returned.

- (void)requestFinished:(ASIHTTPRequest *)request
{
   // Use when fetching text data
    NSString *responseString = [request responseString];

    // do something to turn responseString into the data you'll use to 
    // populate your table with data, and then:

    [myTable reloadData];
} 

So the table will come up empty, and will reload itself once you've got your data to display.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜