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];}