You should implement URLSession:task:didCompleteWithError:
and it should report meaningful errors, if any.
In terms of sorts of issues that would work on simulator and not the device, they include (a) use of localhost in the URL; (b) use of URLs only available on LAN and iOS device not connecting successfully via wifi, e.g. perhaps only connecting via cellular; etc. You'd have to share more about the type of URL you are connecting to.
According to the documentation, NSURLErrorDomain
error -999
is NSURLErrorCancelled
. I'm unclear as to why you would get that particular error in this context, unless you were explicitly canceling the request or invalidating the session.