0

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.

Jakub
  • 13,712
  • 17
  • 82
  • 139
  • Why not use the delegate methods? Because you have a completion handler block to be called? – Wain Nov 29 '13 at 12:24
  • Becouse i'm using background fetching iOS7 feature, and want this method to be as clean as possible, don't separate it to another class and don't be messy in AppDelegate. – Jakub Nov 29 '13 at 12:37

1 Answers1

1

try this:

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

         if ([data length] >0 && error == nil)
         {
         }
    }];
thorb65
  • 2,696
  • 2
  • 27
  • 37