Error URLSession didCompleteWithError nil

Work on an IOS9 application that runs the background URL in the controller, which is NSURLSessionDelegate. Here's how I get started:

    self.session_data = [[NSMutableData alloc] init];
    NSURL *url = [NSURL URLWithString:src];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];

    NSURLSessionConfiguration *backgroundConfigObject = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier: @"myBackgroundSessionIdentifier"];
    self.session = [NSURLSession sessionWithConfiguration: backgroundConfigObject delegate: self delegateQueue: [NSOperationQueue mainQueue]];

    self.download = [self.session dataTaskWithRequest: request ];
    [self.download resume];

So far so good. I implement three delegate methods. First, 'didReceiveData' is called, and I store the data.

- (void)URLSession:(NSURLSession *)session
      dataTask:(NSURLSessionDataTask *)dataTask
     didReceiveData:(NSData *)data{

   NSLog(@"%s",__func__);
   [self.session_data appendData:data];
}

Immediately after that, 'didCompleteWithError' is called. The "completeHandler" handler is never called.

What is puzzling about the “didCompleteWithError” message is that the actual error object is zero. I saw some similar unanswered questions. I do not leave the controller / view at boot time. Do I need to move this functionality to AppDelegate?

+4
1

Apple doc , didCompleteWithError , - nil:

" . , , - ,, ."

.

, ,

- URLSession:didBecomeInvalidWithError:

.

+3

All Articles