Reputation: 31
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
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