如何使用并发队列进行异步请求?

how to make asynchronous request using concurrent queues?

有人可以帮助我了解如何使用并发队列发送异步请求。大多数讨论看起来都没有答案。

以下是我编写的代码。当我的请求被获取时,我的 ui 显示 activity 指示器。获取响应后,将显示下一个屏幕

    __block NSData *postReply;
 __block NSDictionary *jsonDict;
myQueue = dispatch_queue_create("myQueue", Nil);
dispatch_async(myQueue, ^{
    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue currentQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
        NSLog(@"%@",request);
 jsonDict=(NSDictionary*)[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
 postReply=data;
        dispatch_async(dispatch_get_main_queue(), ^{
            if ([[jsonDict objectForKey:@"result"]isEqualToString:@"Success"]) {

                UIStoryboard *strObj=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
                ViewController1 *v1=[strObj instantiateViewControllerWithIdentifier:@"view1"];
                [self presentViewController:v1 animated:YES completion:^{
                    [activityIndicator stopAnimating];
                    [activityIndicator removeFromSuperview];
                }];
            }

        });

    }];
});
 __block NSData *postReply;
    __block NSDictionary *jsonDict;

        [activityIndicator startAnimating];
        [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue currentQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
            NSLog(@"%@",request);
            jsonDict=(NSDictionary*)[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
            postReply=data;
                if ([[jsonDict objectForKey:@"result"]isEqualToString:@"Success"]) {

                    UIStoryboard *strObj=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
                    ViewController1 *v1=[strObj instantiateViewControllerWithIdentifier:@"view1"];
                    [self presentViewController:v1 animated:YES completion:^{
                        [activityIndicator stopAnimating];
                        [activityIndicator removeFromSuperview];
                    }];
                }



        }];

我想这可能对你有帮助。