ParameterEncoding
Used to specify the way in which a set of parameters are applied to a URL request.
-
Creates a URL request by encoding parameters and applying them onto an existing request.
Declaration
Swift
public func encode(URLRequest: URLRequestConvertible, parameters: [String : AnyObject]?) -> (NSURLRequest, NSError?)
Parameters
URLRequest
The request to have parameters applied
parameters
The parameters to apply
Return Value
A tuple containing the constructed request and the error that occurred during parameter encoding, if any.
-
Uses
NSPropertyListSerialization
to create a plist representation of the parameters object, according to the associated format and write options values, which is set as the body of the request. TheContent-Type
HTTP header field of an encoded request is set toapplication/x-plist
. -
Uses
NSJSONSerialization
to create a JSON representation of the parameters object, which is set as the body of the request. TheContent-Type
HTTP header field of an encoded request is set toapplication/json
. -
A query string to be set as or appended to any existing URL query for
GET
,HEAD
, andDELETE
requests, or set as the body for requests with any other HTTP method. TheContent-Type
HTTP header field of an encoded request with HTTP body is set toapplication/x-www-form-urlencoded
. Since there is no published specification for how to encode collection types, the convention of appending[]
to the key for array values (foo[]=1&foo[]=2
), and appending the key surrounded by square brackets for nested dictionary values (foo[bar]=baz
). -
Uses the associated closure value to construct a new request given an existing request and parameters.
-
Undocumented
-
Undocumented