Question

In my app I use ASIFormDataRequest to post and get data on the web. But when I build my app for the App Store (using ad-hoc build) some of these requests are simply not called! This ruins my app.

Does someone knows why? What is the difference between an build with Xcode and the app build for the App Store?

I call my request using :

 NSString *stringURL = @"http://myserv.com";
 NSURL *urlPosting = [NSURL URLWithString:stringURL];

            __weak ASIFormDataRequest *requestFormBase1 = [ASIFormDataRequest requestWithURL:urlPosting];


            [requestFormBase1 addPostValue:valueToPost forKey:@"key"];


            [requestFormBase1 startAsynchronous];

            [requestFormBase1 setCompletionBlock:^{

  ...

Thank you very much.

Was it helpful?

Solution

This Sample works for me.

dispatch_queue_t queue = dispatch_queue_create("_downloadQueue", NULL);
dispatch_async(queue, ^(void){
    NSString *_apiURL = @"http://yours.com";
    __weak ASIFormDataRequest *formRequest = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:_apiURL]];
    [formRequest setCompletionBlock:^{
        NSLog(@"response string : %@", [formRequest responseString]);
        dispatch_async(dispatch_get_main_queue(), ^(void) {
            //To execute the UIs.
        });
    }];
    [formRequest setFailedBlock:^{
        dispatch_async(dispatch_get_main_queue(), ^(void) {
            //To execute the UIs.
        });
    }];
    [formRequest startAsynchronous];
});

And in your code, may you need to change the execute process about " [requestFormBase1 startAsynchronous]; " to be last running, like this :

NSString *stringURL = @"http://myserv.com";
NSURL *urlPosting = [NSURL URLWithString:stringURL];
__weak ASIFormDataRequest *requestFormBase1 = [ASIFormDataRequest requestWithURL:urlPosting];
[requestFormBase1 addPostValue:valueToPost forKey:@"key"];
[requestFormBase1 setCompletionBlock:^{ ... }];
[requestFormBase1 startAsynchronous];

This's the Block method running process standard. Hope it will help you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top