PropertyListEncoding

public struct PropertyListEncoding : ParameterEncoding

Uses PropertyListSerialization 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. The Content-Type HTTP header field of an encoded request is set to application/x-plist.

Properties

  • Returns a default PropertyListEncoding instance.

    Declaration

    Swift

    public static var `default`: PropertyListEncoding { get }
  • xml

    Returns a PropertyListEncoding instance with xml formatting and default writing options.

    Declaration

    Swift

    public static var xml: PropertyListEncoding { get }
  • Returns a PropertyListEncoding instance with binary formatting and default writing options.

    Declaration

    Swift

    public static var binary: PropertyListEncoding { get }
  • The property list serialization format.

    Declaration

    Swift

    public let format: PropertyListSerialization.PropertyListFormat
  • The options for writing the parameters as plist data.

    Declaration

    Swift

    public let options: PropertyListSerialization.WriteOptions

Initialization

  • Creates a PropertyListEncoding instance using the specified format and options.

    Declaration

    Swift

    public init(
    	format: PropertyListSerialization.PropertyListFormat = .xml,
    	options: PropertyListSerialization.WriteOptions = 0)

    Parameters

    format

    The property list serialization format.

    options

    The options for writing the parameters as plist data.

    Return Value

    The new PropertyListEncoding instance.

Encoding

  • Creates a URL request by encoding parameters and applying them onto an existing request.

    Throws

    An Error if the encoding process encounters an error.

    Declaration

    Swift

    public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest

    Parameters

    urlRequest

    The request to have parameters applied.

    parameters

    The parameters to apply.

    Return Value

    The encoded request.