问题
When testing my app with connectivity turned off (wifi and cellular off), I am able to catch the error. But, in the Xcode console, I can also see the error messages. My code is not printing these to the console. Are these supposed to appear? Can I ignore them?
Task .<1> HTTP load failed (error code: -1009 [1:50]) 2019-07-10 23:33:42.953046-0700 CodeSample[7157:942572] Task .<1> finished with error - code: -1009
The error codes are picked up here:
`let task = session.dataTask(with: request, completionHandler: { (data: Data?, response: URLResponse?, error: Error?) -> Void in
if error == nil {
// do non error stuff
} else {
// error handling here
}`
回答1:
Those are system logs printed by the OS. You can disable them from your active scheme.
Edit your scheme and add an environment variable as shown at the image below.
来源:https://stackoverflow.com/questions/56983273/are-nsurlerrordomain-error-messages-supposed-to-appear-in-the-xcode-console