zoukankan      html  css  js  c++  java
  • ios网络:应用一个请求的7个步骤

    Splitting big tasks into small tasks is often one of the best ways to solve a problem. Thus, in the next few exercises, we will split each request/method into a 7 step process. In the source code, I have commented each of these steps to assist you as you implement the requests.

    7 Step Process

    1. Set the parameters
    2. Build the URL
      • Combine the base URL, the method being used, and the parameters to create the final URL for the request
    3. Configure the request
      • Create a NSURLRequest or NSMutableURLRequest using the URL
      • (If necessary) When using a NSMutableURLRequest, you may need to configure the request's header fields and HTTP body
    4. Make the request
      • Using the shared NSURLSession singleton, issue the request and specify a completion handler
    5. Parse the data
      • Assuming there is no error when the request returns, parse the response data into a usable type like a NSDictionaryNSArray, or [String:AnyObject], ...
    6. Use the data!
      • Extract the data required for the specified task
    7. Start the request
      • To initiate the request, it must be started (resumed)
  • 相关阅读:
    Safari-IoS调试
    前端加密技术
    gulp入门
    xss攻击
    xml 解析
    python 基本语法
    python初识
    字节
    神奇的算式
    linux-虚拟机安装
  • 原文地址:https://www.cnblogs.com/dagon/p/4782415.html
Copyright © 2011-2022 走看看