1
votes

This is more of a design question. I have a single ViewController which manages a UITableView. The user can add/edit/delete items in this tableview. Changes to this tableview are persisted in my back end database via web service calls. I am using ASIHTTPRequest to wrap these web service calls. ASIHTTPRequest requests are given a delegate object which should implement -(void)requestFinished:request and -(void)requestFailed:request.

Obviously my implementation of -(void)requestFinished:request will be different depending on whether the user is deleting a record or refreshing the tableview. How is this typically handled? Should I implement a unique delegate for different types of requests, set 'status'flags in the view controller to indicate which request is in progress or something else?

Thanks!

3
hey mate give the tag to every request and after check with request.tag in your delegate method.. :)Paras Joshi
Oh nice. I didn't know about the 'tag' property. Thanks!Nick

3 Answers

0
votes

You should follow documentation of ASIHTTPRequest

Handling success and failure for multiple requests in delegate methods

http://allseeing-i.com/ASIHTTPRequest/How-to-use

Hope this will help you out.

0
votes

You should give tag to each request you're making.

- (void)requestFinished:(ASIHTTPRequest *)request
{

    //Here you can differentiate each request using request.tag for individual request success

}

- (void)requestFailed:(ASIHTTPRequest *)request
{
    //Here you can differentiate each request using request.tag for individual request error
}
0
votes

try bellow code...

- (void)requestFinished:(ASIHTTPRequest *)request
{

     if (request.tag == 1) { // 1 just an example
         /// do something here
     }
     else if (request.tag == 2) {
         /// do something here
     }
}

 - (void)requestFailed:(ASIHTTPRequest *)request
{

     if (request.tag == 1) { // 1 just an example
         /// do something here
     }
     else if (request.tag == 2) {
         /// do something here
     }
}

i hope this help you...

:)