0

In iOS, the Xcode/Swift method to load an HTTP request is void, and returns no value.

Why not return the response code? For example, on a successful page request, return 200; on a not found, return 404.

I know that the status variable can be pulled from the header in the WebViewDidFinishLoad Method (ref link below), but it seems that a return code directly from the loadRequest method would make sense.

EDIT: Updated clip from documentation

enter image description here

Get the http response code from every UIWebView request

Community
  • 1
  • 1
kmiklas
  • 13,085
  • 22
  • 67
  • 103
  • You know that loadHTMLString just loads the (HTML) content of the provided string into the web view, right? It doesn't make an HTTP request, per se. What exactly are you trying to do? – Matt Gibson Jun 11 '14 at 15:52
  • Oops! Sry, clipped the wrong snippet from the docs--updated. I'm trying to get the HTTP response code from a UIWebView loadRequest call. – kmiklas Jun 11 '14 at 16:11

1 Answers1

1

Ah, so you meant loadRequest? As you can see from the docs you've quoted, it's asynchronous, so it will almost certainly return before the request has completed, so it can't return the response code as the response hasn't happened yet.

Matt Gibson
  • 37,886
  • 9
  • 99
  • 128