1

I have the following code:

NSDictionary *parameters = @{@"parameter1":objectVariable1,@"parameter2":objectVariable2};
[MANAGER POST:@"http:www.myserver.com/somelink" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject)
 {
     //PROCESS RESPONSE
 }
      failure:^(AFHTTPRequestOperation *operation, NSError *error)
 {
     //PROCESS FAILURE
 }];

In case of failure how do I retry this connection considering the objectVariable1 & objectVariable2 can change at any point (while the connection is sent to the server) thus the same post parameters as before must be sent.
Can the parameters be obtained from AFHTTPRequestOperation *operation in the error branch?

Just to be sure, for example, this can be the case:
- objectVariable1 = 1
- send connection with objectVariable1 = 1
- objectVariable1 = 2
- connection fails and should retry with objectVariable1 = 1

Larme
  • 24,190
  • 6
  • 51
  • 81
Petrescu Silviu
  • 247
  • 1
  • 11

1 Answers1

0

Quick and dirty solution:

-(void) post: (NSString *) post withParams: (NSDictionary *) params andReplies: (NSInteger) replies
{
    [MANAGER POST:post parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject)
     {
         //PROCESS RESPONSE
     }
          failure:^(AFHTTPRequestOperation *operation, NSError *error)
     {
         //PROCESS FAILURE
        if (replies > 0) {
            [self post: post withParams: params andReplies: replies - 1];
        }
     }];
}
Andy
  • 376
  • 4
  • 19
  • This doesn't work because that was just an example. `objectVariable1` can become any value and I don't want to keep a backup of it. I wanted to know if I can somehow extract from the `operation` variable the post parameters and re-use them in a new connection. – Petrescu Silviu Oct 30 '15 at 13:44