I am building an app that uses a web service and to get information from that web service I use NSURLSession
and NSURLSessionDataTask
.
I am now
After rereading the URL Loading System Programming Guide it turns that I was setting the NSURLSession
property to nil too early.
Instead, I need to set the NSURLSession
property to nil AFTER I receive the delegate message URLSession:(NSURLSession *)session didBecomeInvalidWithError:(NSError *)error
, which makes sense. Luckily, it was a minor mistake.
E.g.
- (void)URLSession:(NSURLSession *)session didBecomeInvalidWithError:(NSError *)error
{
if (error)
{
#ifdef DEBUG
NSLog(@"[GPPhotoRequest] Session Invalidation: %@", [error description]);
#endif
}
if ([session isEqual:_session])
{
[self cleanupSession];
}
}