At the moment I have an asynchronous download (the download does not stop the program), I need the program to load the data in this section of the code and only then continue (synchronous loading), how to implement it?

NSURL *url = [NSURL URLWithString:lineURLresult]; // URL NSURLSessionDataTask *downloadTask = [[NSURLSession sharedSession] dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { id object = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error]; { if ([object isKindOfClass:[NSDictionary class]] && error == nil){ id object = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error]; [_tableViewData addObject:object]; dispatch_async(dispatch_get_main_queue(), ^{ // обновление UI }); } } }]; 

    1 answer 1

    Before starting the request, programmatically overlay the View, which is best blurred (this will block clicking on the elements below) and add an endless progress bar.

     @property (strong, nonatomic) UIView* workView; self.workView = [[UIView alloc] init]; self.workView.frame = self.view.frame; [self.view addSubview:self.workView]; self.workView.center = self.view.center; [self.view bringSubviewToFront:self.workView]; // отправляем на передний план 

    When receiving a response from the server or an error - delete this View and progress bar.

     [self.workView removeFromSuperview]; 

    How to add and remove the progress bar did not begin to describe, select the appropriate one on cocoacontrols