I load the data in the loading screen (viewDidLoad). All attempts to save the received data are unsuccessful: if you add via addObject, the array remains empty (displays nil), although there are data that we are trying to add — exist (output data); id object — stores all the data in full (it can be output) but as soon as we exit the body of this request, the data disappears (the testIdData class variable is empty after the request body, and in the data body). In general, a silly question, but how can I get this data out of the body? JSON input
- (void)viewDidLoad { [super viewDidLoad]; tableViewData = [NSMutableArray new]; // создаем запрос 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 object2 = [tableViewData objectAtIndex:0]; id object = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error]; [_tableViewData addObject:object]; NSLog(@"%@",tableViewData); // Скриншот результата 1 } } }]; [downloadTask resume]; NSLog(@"%@",tableViewData); // Скриншот результата 2 Variables of the viewController class in which the request is located
@interface ViewControllerTable : UIViewController <UITableViewDelegate, UITableViewDataSource>{ } @property (strong, nonatomic)NSMutableArray *tableViewData; Screenshot 2

