POST request without NSURLConnectionDelegate

129 views Asked by At

I would like to send POST request but without using delegate. I have to have everything in a block. I'm also didn't want to use AFNetworking for this simple task. Why? I have only one request in my app and doesn't feel like including 3-party library for this kind (i think easy) stuff.

I want to send dispatch block request at -(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler method.

1

There are 1 answers

0
thorb65 On BEST ANSWER

try this:

    [NSURLConnection sendAsynchronousRequest:self.request
                                       queue:[[NSOperationQueue alloc] init]
                           completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {

         if ([data length] >0 && error == nil)
         {
         }
    }];