Handle HTTP error with NSURLSession?

前端 未结 5 1308
挽巷
挽巷 2021-01-07 16:33

I\'m trying to send a HTTP request with NSURLSession. It works fine, but when the server doesn\'t respond I can\'t find where the HTTP error code is stored. The

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-07 17:20

    If server-side error occurred data parameter from completion handler may contain some useful info

    In general I thin you should implement URLSession:task:didCompleteWithError: from NSURLSessionTaskDelegate protocol in session delegate

    docs: NSURLSessionTaskDelegate Protocol Reference

提交回复
热议问题