Create a GET request when a button is clicked
NSLog (@ "NO") and NSLog (@ "YES") are displayed instantly when pressed, all further code is executed only after ~ 40 seconds (output message from a received request, switching to another screen), and switching to another screen generally drops, 
- (IBAction)buttonConnect:(id)sender { 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){ if([[object objectForKey:@"Success"] boolValue] == FALSE){ NSLog(@"NO"); _labelStatus.text = [object objectForKey:@"Message"]; } else { NSLog(@"True"); _labelStatus.text = @"YES"; // Переход на VievControllerTable ViewControllerTable *detail = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewControllerTable"]; [self.navigationController pushViewController:detail animated:YES]; } } }]; [downloadTask resume]; } There are no such problems with NSURLConnection.
- (IBAction)buttonConnect:(id)sender { // создаем запрос NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:lineURLresult] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:15.0]; // создаём соединение и начинаем загрузку NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; if (connection) { // соединение началось _labelStatus.text = @"Подключение..."; // создаем NSMutableData, чтобы сохранить полученные данные receivedData = [NSMutableData data]; } else { // при попытке соединиться произошла ошибка _labelStatus.text = @"Произошла ошибка!"; } } - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { // получен ответ от сервера [receivedData setLength:0]; } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { // добавляем новые данные к receivedData [receivedData appendData:data]; } - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { // выводим сообщение об ошибке NSString *errorString = [[NSString alloc] initWithFormat:@"Ошибка подключения"]; _labelStatus.text = errorString; } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { // Результат подключения NSError *error = nil; id object = [NSJSONSerialization JSONObjectWithData:receivedData options:NSJSONReadingAllowFragments error:&error]; if([[object objectForKey:@"Success"] boolValue] == FALSE) _labelStatus.text = [object objectForKey:@"Message"]; else { _labelStatus.text = @""; // Сохранение [[NSUserDefaults standardUserDefaults] setValue:self.lineNameProfile forKey:@"lineNameProfile"]; [[NSUserDefaults standardUserDefaults] setValue:self.linePassword forKey:@"linePassword"]; [[NSUserDefaults standardUserDefaults] synchronize]; // Переход на VievControllerTable ViewControllerTable *detail = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewControllerTable"]; [self.navigationController pushViewController:detail animated:YES]; } }