SHARE
TWEET

Untitled

a guest May 19th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fileprivate func configureParameters(bodyParameters: Parameters?,
  2.                                      urlParameters: Parameters?,
  3.                                      request: inout URLRequest) throws {
  4.     do {
  5.         // bodyParameters 為 JSON 格式,使用 JSONParameterEncoder 來編碼
  6.         if let bodyParameters = bodyParameters {
  7.             try JSONParameterEncoder.encode(urlRequest: &request, with: bodyParameters)
  8.         }
  9.       // urlParameters 為 URL 編碼,使用 JSONParameterEncoder 來編碼
  10.         if let urlParameters = urlParameters {
  11.             try URLParameterEncoder.encode(urlRequest: &request, with: urlParameters)
  12.         }
  13.     } catch {
  14.         // 獲取 Encoder 可能拋出的錯誤訊息
  15.         throw error
  16.     }
  17.  
  18. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top