LCURLResponseSerialization

Objective-C

@protocol LCURLResponseSerialization <NSObject, NSSecureCoding, NSCopying>

Swift

protocol LCURLResponseSerialization : NSCopying, NSSecureCoding, NSObjectProtocol

The LCURLResponseSerialization protocol is adopted by an object that decodes data into a more useful object representation, according to details in the server response. Response serializers may additionally perform validation on the incoming response and data.

For example, a JSON response serializer may check for an acceptable status code (2XX range) and content type (application/json), decoding a valid JSON response into an object.

  • The response object decoded from the data associated with a specified response.

    Declaration

    Objective-C

    - (nullable id)responseObjectForResponse:(nullable NSURLResponse *)response
                                        data:(nullable NSData *)data
                                       error:(NSError *_Nullable *_Nullable)error;

    Swift

    func responseObject(for response: URLResponse?, data: Data?, error: NSErrorPointer) -> Any?

    Parameters

    response

    The response to be processed.

    data

    The response data to be decoded.

    error

    The error that occurred while attempting to decode the response data.

    Return Value

    The object decoded from the specified response data.