Web Development
Reading notes: http://www.mincoder.com/article/2576.shtml
The main request method
- GET request: Data in clear text in URL with small amount of data
- Post request: No limit on data size
- 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
- 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)
- 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