简体   繁体   中英

Why does the iOS UIWebView loadRequest method not return a value?

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

在此处输入图片说明

Get the http response code from every UIWebView request

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM