I've got a really strange error. I have the following line in code:
NSURLSessionDataTask *task = [self.session dataTaskWithRequest:request];
after execution of which the task
is nil
! This case is not documented anywhere and I couldn't find any similar cases on the web. The session
is not nil
.
This happens only when I press home to leave the app, come back and do something that sends a request. iOS Simulator 8.3
This is the bug in iOS, sometimes it just returns nil. Workaround for this is to keep calling this method for several times, just like AFNetworking does for uploadTaskWithRequest:
method.