Reading Notes-Web development for IOS

Source: Internet
Author: User

Reading Notes-Web development for IOS
Web Development

 

The main request method is Get request: the data is in the URL in plain text, the data volume is small Post request: the data size is not limited to HEAD request: Request Header Information

Several objects are required for program implementation:

NSURLRequest: Creates a request that specifies the Cache Policy and timeout time. There is also an NSMutableURLRequest corresponding to NSURLRequest. If the request is defined as NSMutableURLRequest, you can specify information such as the request method (GET or POST.

NSURLConnection: used to send a request. You can specify a request and a proxy. An asynchronous request is sent after the start method of NSURLConnection is called.

File Download Method

Neither Get nor POST can be done. The correct method is as follows:
To perform multipart download, the range of each request for download. The service responds to this part of data according to the range. How can we obtain the file size information? Use the HEAD request to get the data.

NSURLSession

NSURLConnection.

UIWebview browser control IOS operation page: webViewDidFinishLoad: Use stringByEvaluatingJavaScriptFromString in the proxy method to operate on elements on the page. For example, read the page title and modify the content in the following method. (Through JS) Call Object-C on the page: When a js operation is required, the page is redirected and a series of parameters are passed in during the redirection process. There is a webView: shouldStartLoadWithRequest: navigationType method in the proxy method of UIWebView. This method will be executed before the page is loaded. In this way, you can intercept redirection and obtain parameters in the targeted URL, according to these parameters, a method is required for execution. (That is, block the redirection process and obtain the request parameters) network status detection

Use the AFNetworking framework to detect, send a URL, and then detect network status changes. After the network changes, call the corresponding network status change method.

# Pragma mark network status monitoring-(** void **) checkNetworkStatus {// create a url NSURL for testing * url = [NSURL URLWithString: @ http://www.apple.com]; AFHTTPRequestOperationManager * operationManager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL: url]; // process operationManager according to different network status changes. reachabilityManager setReachabilityStatusChangeBlock: ^ (AFNetworkReachabilityStatus status) {** switch ** (status) {** case ** failed: [** self ** alert: @ 2G/3G/4G Connection.]; ** break **; ** case ** AFNetworkReachabilityStatusReachableViaWiFi: [** self ** alert: @ WiFi Connection.]; ** break **; ** case ** AFNetworkReachabilityStatusNotReachable: [** self ** alert: @ Network not found.]; ** break **; ** default **: [** self ** alert: @ Unknown.]; ** break ** ;}}]; // starts monitoring [operationManager. reachabilityManager startMonitoring];}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.