Web development of Reading notes--ios

Source: Internet
Author: User

Web Development

Reading notes: http://www.mincoder.com/article/2576.shtml

The main request method
    1. GET request: Data in clear text in URL with small amount of data
    2. Post request: No limit on data size
    3. Head Request: Request header information

The implementation of the program requires several objects:

    • Nsurlrequest: A request was made to specify the cache policy and time-out. There is also a nsmutableurlrequest corresponding to the nsurlrequest, and if the request is defined as Nsmutableurlrequest, you can specify information such as the request method (get or post).

    • Nsurlconnection: For sending requests, you can specify requests and proxies. Starts sending an asynchronous request after the start method of the current call to Nsurlconnection.

How to download files

Both get and post are not working, and the right thing to do is this:
To segment the download, the scope of each request to download, the service responds to this part of the data according to the scope, how to get the file size information? Use head request to get.

Nsurlsession

Nsurlconnection objects of improvement.

UIWebView Browser Controls
    1. iOS action page: webviewdidfinishload: In the proxy method, you can manipulate elements in the page by using the stringbyevaluatingjavascriptfromstring: method, such as reading the page title in the following method, The content is modified. (via JS)
    2. Page called Object-c: 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, which executes before the page is loaded, so that the redirect can be intercepted here. And get the parameters in the directed URL, according to these parameters to contract a method to execute. (That is, the redirection process is stopped and then the requested parameters are obtained)
Network status Detection

Using afnetworking framework detection, send a URL and then detect the network state changes, the network changes will call the corresponding network state change method.

#pragma mark Network condition monitoring-(**void**) checknetworkstatus{    //Create a URL for testing    Nsurl*url=[Nsurlurlwithstring:@"Http://www.apple.com"]; Afhttprequestoperationmanager *operationmanager=[[afhttprequestoperationmanager Alloc]initWithBaseURL:url];//According to different network status changes to do the corresponding processing[Operationmanager. Reachabilitymanagersetreachabilitystatuschangeblock:^ (afnetworkreachabilitystatus status) {* *Switch* * (status) {* * Case* * Afnetworkreachabilitystatusreachableviawwan: [* * 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**; }    }];//Start monitoring[Operationmanager. ReachabilitymanagerStartmonitoring];}

Web development of Reading notes--ios

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.