gattirandagi
gattirandagi

Reputation: 31

NSURLSession in background didCompleteWithError

I'm fighting with NSURLSession upload & download, everything seems to work if not for the fact that, for example, at in the background of 100 files sent (upload) the :

- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error

not always invoked by the system, regardless of the file sent correctly.

More is almost always invoked at the end of the session ...

It is normal behavior or am I making mistakes ... ??

I also did some testing using AFNetworking but I always get the same behavior.

thanks !

Upvotes: 3

Views: 1075

Answers (1)

razor28
razor28

Reputation: 1077

In my case delegate method func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) was not called in Swift 3.0 because it still depends on Objective-C. So please use next code for delegate method:

@objc(URLSession:task:didCompleteWithError:)
func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {
  //your code here
}

Upvotes: 1

Related Questions