AFNetworkReachabilityManager Class Reference

AFNetworkReachabilityManager Class Reference

Inherits from NSObject
Declared in AFNetworkReachabilityManager.h
AFNetworkReachabilityManager.m

Overview

AFNetworkReachabilityManager monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces.

Reachability can be used to determine background information about why a network operation failed, or to trigger a network operation retrying when a connection is established. It should not be used to prevent a user from initiating a network request, as it’s possible that an initial request may be required to establish reachability.

See Apple’s Reachability Sample Code ( https://developer.apple.com/library/ios/samplecode/reachability/ )

Warning: Instances of AFNetworkReachabilityManager must be started with startMonitoring before reachability status can be determined.

Queue a status change notification for the main thread.

This is done to ensure that the notifications are received in the same order as they are sent. If notifications are sent directly, it is possible that a queued notification (for an earlier status condition) is processed after the later update, resulting in the listener being left in the wrong state.

Other Methods

  networkReachabilityStatus

The current network reachability status.

@property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus

Declared In

AFNetworkReachabilityManager.h

  reachable

Whether or not the network is currently reachable.

@property (readonly, nonatomic, assign, getter=isReachable) BOOL reachable

Declared In

AFNetworkReachabilityManager.h

  reachableViaWWAN

Whether or not the network is currently reachable via WWAN.

@property (readonly, nonatomic, assign, getter=isReachableViaWWAN) BOOL reachableViaWWAN

Declared In

AFNetworkReachabilityManager.h

  reachableViaWiFi

Whether or not the network is currently reachable via WiFi.

@property (readonly, nonatomic, assign, getter=isReachableViaWiFi) BOOL reachableViaWiFi

Declared In

AFNetworkReachabilityManager.h

Initialization

+ sharedManager

Returns the shared network reachability manager.

+ (instancetype)sharedManager

Declared In

AFNetworkReachabilityManager.h

+ manager

Creates and returns a network reachability manager with the default socket address.

+ (instancetype)manager

Return Value

An initialized network reachability manager, actively monitoring the default socket address.

Declared In

AFNetworkReachabilityManager.h

+ managerForDomain:

Creates and returns a network reachability manager for the specified domain.

+ (instancetype)managerForDomain:(NSString *)domain

Parameters

domain

The domain used to evaluate network reachability.

Return Value

An initialized network reachability manager, actively monitoring the specified domain.

Declared In

AFNetworkReachabilityManager.h

+ managerForAddress:

Creates and returns a network reachability manager for the socket address.

+ (instancetype)managerForAddress:(const void *)address

Parameters

address

The socket address (sockaddr_in6) used to evaluate network reachability.

Return Value

An initialized network reachability manager, actively monitoring the specified socket address.

Declared In

AFNetworkReachabilityManager.h

– initWithReachability:

Initializes an instance of a network reachability manager from the specified reachability object.

- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability

Parameters

reachability

The reachability object to monitor.

Return Value

An initialized network reachability manager, actively monitoring the specified reachability.

Declared In

AFNetworkReachabilityManager.h

Starting & Stopping Reachability Monitoring

– startMonitoring

Starts monitoring for changes in network reachability status.

- (void)startMonitoring

Declared In

AFNetworkReachabilityManager.h

– stopMonitoring

Stops monitoring for changes in network reachability status.

- (void)stopMonitoring

Declared In

AFNetworkReachabilityManager.h

Getting Localized Reachability Description

– localizedNetworkReachabilityStatusString

Returns a localized string representation of the current network reachability status.

- (NSString *)localizedNetworkReachabilityStatusString

Declared In

AFNetworkReachabilityManager.h

Setting Network Reachability Change Callback

– setReachabilityStatusChangeBlock:

Sets a callback to be executed when the network availability of the baseURL host changes.

- (void)setReachabilityStatusChangeBlock:(nullable void ( ^ ) ( AFNetworkReachabilityStatus status ))block

Parameters

block

A block object to be executed when the network availability of the baseURL host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the baseURL.

Declared In

AFNetworkReachabilityManager.h

UIButton(AFNetworking) Category Reference

UIButton(AFNetworking) Category Reference

Declared in UIButton+AFNetworking.h
UIButton+AFNetworking.m

Overview

This category adds methods to the UIKit framework’s UIButton class. The methods in this category provide support for loading remote images and background images asynchronously from a URL.

Warning: Compound values for control state (such as UIControlStateHighlighted | UIControlStateDisabled) are unsupported.

Accessing the Image Downloader

+ setSharedImageDownloader:

Set the shared image downloader used to download images.

+ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader

Parameters

imageDownloader

The shared image downloader used to download images.

Declared In

UIButton+AFNetworking.h

+ sharedImageDownloader

The shared image downloader used to download images.

+ (AFImageDownloader *)sharedImageDownloader

Declared In

UIButton+AFNetworking.h

Setting Image

– setImageForState:withURL:

Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.

- (void)setImageForState:(UIControlState)state withURL:(NSURL *)url

Parameters

state

The control state.

url

The URL used for the image request.

Discussion

If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.

Declared In

UIButton+AFNetworking.h

– setImageForState:withURL:placeholderImage:

Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.

- (void)setImageForState:(UIControlState)state withURL:(NSURL *)url placeholderImage:(nullable UIImage *)placeholderImage

Parameters

state

The control state.

url

The URL used for the image request.

placeholderImage

The image to be set initially, until the image request finishes. If nil, the button will not change its image until the image request finishes.

Discussion

If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.

Declared In

UIButton+AFNetworking.h

– setImageForState:withURLRequest:placeholderImage:success:failure:

Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.

- (void)setImageForState:(UIControlState)state withURLRequest:(NSURLRequest *)urlRequest placeholderImage:(nullable UIImage *)placeholderImage success:(nullable void ( ^ ) ( NSURLRequest *request , NSHTTPURLResponse *_Nullable response , UIImage *image ))success failure:(nullable void ( ^ ) ( NSURLRequest *request , NSHTTPURLResponse *_Nullable response , NSError *error ))failure

Parameters

state

The control state.

urlRequest

The URL request used for the image request.

placeholderImage

The image to be set initially, until the image request finishes. If nil, the button will not change its image until the image request finishes.

success

A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be nil.

failure

A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.

Discussion

If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.

If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with setImage:forState: is applied.

Declared In

UIButton+AFNetworking.h

Setting Background Image

– setBackgroundImageForState:withURL:

Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous background image request for the receiver will be cancelled.

- (void)setBackgroundImageForState:(UIControlState)state withURL:(NSURL *)url

Parameters

state

The control state.

url

The URL used for the background image request.

Discussion

If the background image is cached locally, the background image is set immediately, otherwise the specified placeholder background image will be set immediately, and then the remote background image will be set once the request is finished.

Declared In

UIButton+AFNetworking.h

– setBackgroundImageForState:withURL:placeholderImage:

Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.

- (void)setBackgroundImageForState:(UIControlState)state withURL:(NSURL *)url placeholderImage:(nullable UIImage *)placeholderImage

Parameters

state

The control state.

url

The URL used for the background image request.

placeholderImage

The background image to be set initially, until the background image request finishes. If nil, the button will not change its background image until the background image request finishes.

Discussion

If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.

Declared In

UIButton+AFNetworking.h

– setBackgroundImageForState:withURLRequest:placeholderImage:success:failure:

Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.

- (void)setBackgroundImageForState:(UIControlState)state withURLRequest:(NSURLRequest *)urlRequest placeholderImage:(nullable UIImage *)placeholderImage success:(nullable void ( ^ ) ( NSURLRequest *request , NSHTTPURLResponse *_Nullable response , UIImage *image ))success failure:(nullable void ( ^ ) ( NSURLRequest *request , NSHTTPURLResponse *_Nullable response , NSError *error ))failure

Parameters

state

The control state.

urlRequest

The URL request used for the image request.

placeholderImage

The background image to be set initially, until the background image request finishes. If nil, the button will not change its background image until the background image request finishes.

success

A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be nil.

failure

A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.

Discussion

If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.

If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with setBackgroundImage:forState: is applied.

Declared In

UIButton+AFNetworking.h

Canceling Image Loading

– cancelImageDownloadTaskForState:

Cancels any executing image task for the specified control state of the receiver, if one exists.

- (void)cancelImageDownloadTaskForState:(UIControlState)state

Parameters

state

The control state.

Declared In

UIButton+AFNetworking.h

– cancelBackgroundImageDownloadTaskForState:

Cancels any executing background image task for the specified control state of the receiver, if one exists.

- (void)cancelBackgroundImageDownloadTaskForState:(UIControlState)state

Parameters

state

The control state.

Declared In

UIButton+AFNetworking.h

AFAutoPurgingImageCache Class Reference

AFAutoPurgingImageCache Class Reference

Inherits from NSObject
Conforms to AFImageRequestCache
Declared in AFAutoPurgingImageCache.h
AFAutoPurgingImageCache.m

Overview

The AutoPurgingImageCache in an in-memory image cache used to store images up to a given memory capacity. When the memory capacity is reached, the image cache is sorted by last access date, then the oldest image is continuously purged until the preferred memory usage after purge is met. Each time an image is accessed through the cache, the internal access date of the image is updated.

Other Methods

  memoryCapacity

The total memory capacity of the cache in bytes.

@property (nonatomic, assign) UInt64 memoryCapacity

Declared In

AFAutoPurgingImageCache.h

  preferredMemoryUsageAfterPurge

The preferred memory usage after purge in bytes. During a purge, images will be purged until the memory capacity drops below this limit.

@property (nonatomic, assign) UInt64 preferredMemoryUsageAfterPurge

Declared In

AFAutoPurgingImageCache.h

  memoryUsage

The current total memory usage in bytes of all images stored within the cache.

@property (nonatomic, assign, readonly) UInt64 memoryUsage

Declared In

AFAutoPurgingImageCache.h

– init

Initialies the AutoPurgingImageCache instance with default values for memory capacity and preferred memory usage after purge limit. memoryCapcity defaults to 100 MB. preferredMemoryUsageAfterPurge defaults to 60 MB.

- (instancetype)init

Return Value

The new AutoPurgingImageCache instance.

Declared In

AFAutoPurgingImageCache.h

– initWithMemoryCapacity:preferredMemoryCapacity:

Initialies the AutoPurgingImageCache instance with the given memory capacity and preferred memory usage after purge limit.

- (instancetype)initWithMemoryCapacity:(UInt64)memoryCapacity preferredMemoryCapacity:(UInt64)preferredMemoryCapacity

Parameters

memoryCapacity

The total memory capacity of the cache in bytes.

preferredMemoryCapacity

The preferred memory usage after purge in bytes.

Return Value

The new AutoPurgingImageCache instance.

Declared In

AFAutoPurgingImageCache.h

Other Methods

– addImage:forRequest:withAdditionalIdentifier:

Adds the image to the cache using an identifier created from the request and additional identifier.

- (void)addImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier

Parameters

image

The image to cache.

request

The unique URL request identifing the image asset.

identifier

The additional identifier to apply to the URL request to identify the image.

Declared In

AFAutoPurgingImageCache.h

– removeImageforRequest:withAdditionalIdentifier:

Removes the image from the cache using an identifier created from the request and additional identifier.

- (BOOL)removeImageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier

Parameters

request

The unique URL request identifing the image asset.

identifier

The additional identifier to apply to the URL request to identify the image.

Return Value

A BOOL indicating whether or not all images were removed from the cache.

Declared In

AFAutoPurgingImageCache.h

– imageforRequest:withAdditionalIdentifier:

Returns the image from the cache associated with an identifier created from the request and additional identifier.

- (nullable UIImage *)imageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier

Parameters

request

The unique URL request identifing the image asset.

identifier

The additional identifier to apply to the URL request to identify the image.

Return Value

An image for the matching request and identifier, or nil.

Declared In

AFAutoPurgingImageCache.h

AFCompoundResponseSerializer Class Reference

AFCompoundResponseSerializer Class Reference

Inherits from AFHTTPResponseSerializer : NSObject
Declared in AFURLResponseSerialization.h
AFURLResponseSerialization.m

Overview

AFCompoundSerializer is a subclass of AFHTTPResponseSerializer that delegates the response serialization to the first AFHTTPResponseSerializer object that returns an object for responseObjectForResponse:data:error:, falling back on the default behavior of AFHTTPResponseSerializer. This is useful for supporting multiple potential types and structures of server responses with a single serializer.

  responseSerializers

The component response serializers.

@property (readonly, nonatomic, copy) NSArray<id<AFURLResponseSerialization> > *responseSerializers

Declared In

AFURLResponseSerialization.h

+ compoundSerializerWithResponseSerializers:

Creates and returns a compound serializer comprised of the specified response serializers.

+ (instancetype)compoundSerializerWithResponseSerializers:(NSArray<id<AFURLResponseSerialization> > *)responseSerializers

Discussion

Warning: Each response serializer specified must be a subclass of AFHTTPResponseSerializer, and response to -validateResponse:data:error:.

Declared In

AFURLResponseSerialization.h

AFHTTPResponseSerializer Class Reference

AFHTTPResponseSerializer Class Reference

Inherits from NSObject
Conforms to AFURLResponseSerialization
Declared in AFURLResponseSerialization.h
AFURLResponseSerialization.m

Overview

AFHTTPResponseSerializer conforms to the AFURLRequestSerialization & AFURLResponseSerialization protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation.

Any request or response serializer dealing with HTTP is encouraged to subclass AFHTTPResponseSerializer in order to ensure consistent default behavior.

Other Methods

  stringEncoding

The string encoding used to serialize data received from the server, when no string encoding is specified by the response. NSUTF8StringEncoding by default.

@property (nonatomic, assign) NSStringEncoding stringEncoding

Declared In

AFURLResponseSerialization.h

+ serializer

Creates and returns a serializer with default configuration.

+ (instancetype)serializer

Declared In

AFURLResponseSerialization.h

Configuring Response Serialization

  acceptableStatusCodes

The acceptable HTTP status codes for responses. When non-nil, responses with status codes not contained by the set will result in an error during validation.

@property (nonatomic, copy, nullable) NSIndexSet *acceptableStatusCodes

Declared In

AFURLResponseSerialization.h

  acceptableContentTypes

The acceptable MIME types for responses. When non-nil, responses with a Content-Type with MIME types that do not intersect with the set will result in an error during validation.

@property (nonatomic, copy, nullable) NSSet<NSString*> *acceptableContentTypes

Declared In

AFURLResponseSerialization.h

– validateResponse:data:error:

Validates the specified response and data.

- (BOOL)validateResponse:(nullable NSHTTPURLResponse *)response data:(nullable NSData *)data error:(NSError *_Nullable __autoreleasing *)error

Parameters

response

The response to be validated.

data

The data associated with the response.

error

The error that occurred while attempting to validate the response.

Return Value

YES if the response is valid, otherwise NO.

Discussion

In its base implementation, this method checks for an acceptable status code and content type. Subclasses may wish to add other domain-specific checks.

Declared In

AFURLResponseSerialization.h

Other Methods

– responseObjectForResponse:data:error:

- (id)responseObjectForResponse:(NSURLResponse *)response data:(NSData *)data error:(NSError *__autoreleasing *)error

Declared In

AFURLResponseSerialization.h

AFHTTPRequestSerializer Class Reference

AFHTTPRequestSerializer Class Reference

Inherits from NSObject
Conforms to AFURLRequestSerialization
Declared in AFURLRequestSerialization.h
AFURLRequestSerialization.m

Overview

AFHTTPRequestSerializer conforms to the AFURLRequestSerialization & AFURLResponseSerialization protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation.

Any request or response serializer dealing with HTTP is encouraged to subclass AFHTTPRequestSerializer in order to ensure consistent default behavior.

Other Methods

  stringEncoding

The string encoding used to serialize parameters. NSUTF8StringEncoding by default.

@property (nonatomic, assign) NSStringEncoding stringEncoding

Declared In

AFURLRequestSerialization.h

  allowsCellularAccess

Whether created requests can use the device’s cellular radio (if present). YES by default.

@property (nonatomic, assign) BOOL allowsCellularAccess

See Also

Declared In

AFURLRequestSerialization.h

  cachePolicy

The cache policy of created requests. NSURLRequestUseProtocolCachePolicy by default.

@property (nonatomic, assign) NSURLRequestCachePolicy cachePolicy

See Also

Declared In

AFURLRequestSerialization.h

  HTTPShouldHandleCookies

Whether created requests should use the default cookie handling. YES by default.

@property (nonatomic, assign) BOOL HTTPShouldHandleCookies

See Also

Declared In

AFURLRequestSerialization.h

  HTTPShouldUsePipelining

Whether created requests can continue transmitting data before receiving a response from an earlier transmission. NO by default

@property (nonatomic, assign) BOOL HTTPShouldUsePipelining

See Also

Declared In

AFURLRequestSerialization.h

  networkServiceType

The network service type for created requests. NSURLNetworkServiceTypeDefault by default.

@property (nonatomic, assign) NSURLRequestNetworkServiceType networkServiceType

See Also

Declared In

AFURLRequestSerialization.h

  timeoutInterval

The timeout interval, in seconds, for created requests. The default timeout interval is 60 seconds.

@property (nonatomic, assign) NSTimeInterval timeoutInterval

See Also

Declared In

AFURLRequestSerialization.h

Configuring HTTP Request Headers

  HTTPRequestHeaders

Default HTTP header field values to be applied to serialized requests. By default, these include the following:

@property (readonly, nonatomic, strong) NSDictionary<NSString*NSString*> *HTTPRequestHeaders

Discussion

  • Accept-Language with the contents of NSLocale +preferredLanguages
  • User-Agent with the contents of various bundle identifiers and OS designations

To add or remove default request headers, use setValue:forHTTPHeaderField:.

Declared In

AFURLRequestSerialization.h

+ serializer

Creates and returns a serializer with default configuration.

+ (instancetype)serializer

Declared In

AFURLRequestSerialization.h

– setValue:forHTTPHeaderField:

Sets the value for the HTTP headers set in request objects made by the HTTP client. If nil, removes the existing value for that header.

- (void)setValue:(nullable NSString *)value forHTTPHeaderField:(NSString *)field

Parameters

value

The value set as default for the specified header, or nil

field

The HTTP header to set a default value for

Declared In

AFURLRequestSerialization.h

– valueForHTTPHeaderField:

Returns the value for the HTTP headers set in the request serializer.

- (nullable NSString *)valueForHTTPHeaderField:(NSString *)field

Parameters

field

The HTTP header to retrieve the default value for

Return Value

The value set as default for the specified header, or nil

Declared In

AFURLRequestSerialization.h

– setAuthorizationHeaderFieldWithUsername:password:

Sets the “Authorization” HTTP header set in request objects made by the HTTP client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header.

- (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username password:(NSString *)password

Parameters

username

The HTTP basic auth username

password

The HTTP basic auth password

Declared In

AFURLRequestSerialization.h

– clearAuthorizationHeader

Clears any existing value for the “Authorization” HTTP header.

- (void)clearAuthorizationHeader

Declared In

AFURLRequestSerialization.h

Configuring Query String Parameter Serialization

  HTTPMethodsEncodingParametersInURI

HTTP methods for which serialized requests will encode parameters as a query string. GET, HEAD, and DELETE by default.

@property (nonatomic, strong) NSSet<NSString*> *HTTPMethodsEncodingParametersInURI

Declared In

AFURLRequestSerialization.h

– setQueryStringSerializationWithStyle:

Set the method of query string serialization according to one of the pre-defined styles.

- (void)setQueryStringSerializationWithStyle:(AFHTTPRequestQueryStringSerializationStyle)style

Parameters

style

The serialization style.

Declared In

AFURLRequestSerialization.h

– setQueryStringSerializationWithBlock:

Set the a custom method of query string serialization according to the specified block.

- (void)setQueryStringSerializationWithBlock:(nullable NSString *( ^ ) ( NSURLRequest *request , id parameters , NSError *__autoreleasing *error ))block

Parameters

block

A block that defines a process of encoding parameters into a query string. This block returns the query string and takes three arguments: the request, the parameters to encode, and the error that occurred when attempting to encode parameters for the given request.

Declared In

AFURLRequestSerialization.h

Creating Request Objects

– requestWithMethod:URLString:parameters:error:

Creates an NSMutableURLRequest object with the specified HTTP method and URL string.

- (NSMutableURLRequest *)requestWithMethod:(NSString *)method URLString:(NSString *)URLString parameters:(nullable id)parameters error:(NSError *_Nullable __autoreleasing *)error

Parameters

method

The HTTP method for the request, such as GET, POST, PUT, or DELETE. This parameter must not be nil.

URLString

The URL string used to create the request URL.

parameters

The parameters to be either set as a query string for GET requests, or the request HTTP body.

error

The error that occurred while constructing the request.

Return Value

An NSMutableURLRequest object.

Discussion

If the HTTP method is GET, HEAD, or DELETE, the parameters will be used to construct a url-encoded query string that is appended to the request’s URL. Otherwise, the parameters will be encoded according to the value of the parameterEncoding property, and set as the request body.

Declared In

AFURLRequestSerialization.h

– multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error:

Creates an NSMutableURLRequest object with the specified HTTP method and URLString, and constructs a multipart/form-data HTTP body, using the specified parameters and multipart form data block. See http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.2

- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method URLString:(NSString *)URLString parameters:(nullable NSDictionary<NSString*,id> *)parameters constructingBodyWithBlock:(nullable void ( ^ ) ( id<AFMultipartFormData> formData ))block error:(NSError *_Nullable __autoreleasing *)error

Parameters

method

The HTTP method for the request. This parameter must not be GET or HEAD, or nil.

URLString

The URL string used to create the request URL.

parameters

The parameters to be encoded and set in the request HTTP body.

block

A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the AFMultipartFormData protocol.

error

The error that occurred while constructing the request.

Return Value

An NSMutableURLRequest object

Discussion

Multipart form requests are automatically streamed, reading files directly from disk along with in-memory data in a single HTTP body. The resulting NSMutableURLRequest object has an HTTPBodyStream property, so refrain from setting HTTPBodyStream or HTTPBody on this request object, as it will clear out the multipart form body stream.

Declared In

AFURLRequestSerialization.h

– requestWithMultipartFormRequest:writingStreamContentsToFile:completionHandler:

Creates an NSMutableURLRequest by removing the HTTPBodyStream from a request, and asynchronously writing its contents into the specified file, invoking the completion handler when finished.

- (NSMutableURLRequest *)requestWithMultipartFormRequest:(NSURLRequest *)request writingStreamContentsToFile:(NSURL *)fileURL completionHandler:(nullable void ( ^ ) ( NSError *_Nullable error ))handler

Parameters

request

The multipart form request. The HTTPBodyStream property of request must not be nil.

fileURL

The file URL to write multipart form contents to.

handler

A handler block to execute.

Discussion

There is a bug in NSURLSessionTask that causes requests to not send a Content-Length header when streaming contents from an HTTP body, which is notably problematic when interacting with the Amazon S3 webservice. As a workaround, this method takes a request constructed with multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error:, or any other request with an HTTPBodyStream, writes the contents to the specified file and returns a copy of the original request with the HTTPBodyStream property set to nil. From here, the file can either be passed to AFURLSessionManager -uploadTaskWithRequest:fromFile:progress:completionHandler:, or have its contents read into an NSData that’s assigned to the HTTPBody property of the request.

Declared In

AFURLRequestSerialization.h

Other Methods

– requestBySerializingRequest:withParameters:error:

Returns a request with the specified parameters encoded into a copy of the original request.

- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request withParameters:(id)parameters error:(NSError *__autoreleasing *)error

Parameters

request

The original request.

parameters

The parameters to be encoded.

error

The error that occurred while attempting to encode the request parameters.

Return Value

A serialized request.

Declared In

AFURLRequestSerialization.h

AFImageDownloadReceipt Class Reference

AFImageDownloadReceipt Class Reference

Inherits from NSObject
Declared in AFImageDownloader.h
AFImageDownloader.m

Overview

The AFImageDownloadReceipt is an object vended by the AFImageDownloader when starting a data task. It can be used to cancel active tasks running on the AFImageDownloader session. As a general rule, image data tasks should be cancelled using the AFImageDownloadReceipt instead of calling cancel directly on the task itself. The AFImageDownloader is optimized to handle duplicate task scenarios as well as pending versus active downloads.

  task

The data task created by the AFImageDownloader.

@property (nonatomic, strong) NSURLSessionDataTask *task

Declared In

AFImageDownloader.h

  receiptID

The unique identifier for the success and failure blocks when duplicate requests are made.

@property (nonatomic, strong) NSUUID *receiptID

Declared In

AFImageDownloader.h

AFHTTPSessionManager Class Reference

AFHTTPSessionManager Class Reference

Inherits from AFURLSessionManager : NSObject
Conforms to NSCopying
NSSecureCoding
Declared in AFHTTPSessionManager.h
AFHTTPSessionManager.m

Overview

AFHTTPSessionManager is a subclass of AFURLSessionManager with convenience methods for making HTTP requests. When a baseURL is provided, requests made with the GET / POST / et al. convenience methods can be made with relative paths.

Subclassing Notes

Developers targeting iOS 7 or Mac OS X 10.9 or later that deal extensively with a web service are encouraged to subclass AFHTTPSessionManager, providing a class method that returns a shared singleton object on which authentication and other configuration can be shared across the application.

For developers targeting iOS 6 or Mac OS X 10.8 or earlier, AFHTTPRequestOperationManager may be used to similar effect.

Methods to Override

To change the behavior of all data task operation construction, which is also used in the GET / POST / et al. convenience methods, override dataTaskWithRequest:completionHandler:.

Serialization

Requests created by an HTTP client will contain default headers and encode parameters according to the requestSerializer property, which is an object conforming to AFURLRequestSerialization.

Responses received from the server are automatically validated and serialized by the responseSerializers property, which is an object conforming to AFURLResponseSerialization

URL Construction Using Relative Paths

For HTTP convenience methods, the request serializer constructs URLs from the path relative to the baseURL, using NSURL +URLWithString:relativeToURL:, when provided. If baseURL is nil, path needs to resolve to a valid NSURL object using NSURL +URLWithString:.

Below are a few examples of how baseURL and relative paths interact:

NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"];
[NSURL URLWithString:@"foo" relativeToURL:baseURL];                  // http://example.com/v1/foo
[NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL];          // http://example.com/v1/foo?bar=baz
[NSURL URLWithString:@"/foo" relativeToURL:baseURL];                 // http://example.com/foo
[NSURL URLWithString:@"foo/" relativeToURL:baseURL];                 // http://example.com/v1/foo
[NSURL URLWithString:@"/foo/" relativeToURL:baseURL];                // http://example.com/foo/
[NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/

Also important to note is that a trailing slash will be added to any baseURL without one. This would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash.

Warning: Managers for background sessions must be owned for the duration of their use. This can be accomplished by creating an application-wide or shared singleton instance.

Other Methods

  baseURL

The URL used to construct requests from relative paths in methods like requestWithMethod:URLString:parameters:, and the GET / POST / et al. convenience methods.

@property (readonly, nonatomic, strong, nullable) NSURL *baseURL

Declared In

AFHTTPSessionManager.h

  requestSerializer

Requests created with requestWithMethod:URLString:parameters: & multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock: are constructed with a set of default headers using a parameter serialization specified by this property. By default, this is set to an instance of AFHTTPRequestSerializer, which serializes query string parameters for GET, HEAD, and DELETE requests, or otherwise URL-form-encodes HTTP message bodies.

@property (nonatomic, strong) AFHTTPRequestSerializer<AFURLRequestSerialization> *requestSerializer

Discussion

Warning: requestSerializer must not be nil.

Declared In

AFHTTPSessionManager.h

  responseSerializer

Responses sent from the server in data tasks created with dataTaskWithRequest:success:failure: and run using the GET / POST / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of AFJSONResponseSerializer.

@property (nonatomic, strong) AFHTTPResponseSerializer<AFURLResponseSerialization> *responseSerializer

Discussion

Warning: responseSerializer must not be nil.

Declared In

AFHTTPSessionManager.h

Initialization

+ manager

Creates and returns an AFHTTPSessionManager object.

+ (instancetype)manager

Declared In

AFHTTPSessionManager.h

– initWithBaseURL:

Initializes an AFHTTPSessionManager object with the specified base URL.

- (instancetype)initWithBaseURL:(nullable NSURL *)url

Parameters

url

The base URL for the HTTP client.

Return Value

The newly-initialized HTTP client

Declared In

AFHTTPSessionManager.h

– initWithBaseURL:sessionConfiguration:

Initializes an AFHTTPSessionManager object with the specified base URL.

- (instancetype)initWithBaseURL:(nullable NSURL *)url sessionConfiguration:(nullable NSURLSessionConfiguration *)configuration

Parameters

url

The base URL for the HTTP client.

configuration

The configuration used to create the managed session.

Return Value

The newly-initialized HTTP client

Discussion

This is the designated initializer.

Declared In

AFHTTPSessionManager.h

Making HTTP Requests

– GET:parameters:success:failure:

Creates and runs an NSURLSessionDataTask with a GET request.

- (nullable NSURLSessionDataTask *)GET:(NSString *)URLString parameters:(nullable id)parameters success:(nullable void ( ^ ) ( NSURLSessionDataTask *task , id _Nullable responseObject ))success failure:(nullable void ( ^ ) ( NSURLSessionDataTask *_Nullable task , NSError *error ))failure

Parameters

URLString

The URL string used to create the request URL.

parameters

The parameters to be encoded according to the client request serializer.

success

A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.

failure

A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.

Declared In

AFHTTPSessionManager.h

– GET:parameters:progress:success:failure:

Creates and runs an NSURLSessionDataTask with a GET request.

- (nullable NSURLSessionDataTask *)GET:(NSString *)URLString parameters:(nullable id)parameters progress:(nullable void ( ^ ) ( NSProgress *downloadProgress ))downloadProgress success:(nullable void ( ^ ) ( NSURLSessionDataTask *task , id _Nullable responseObject ))success failure:(nullable void ( ^ ) ( NSURLSessionDataTask *_Nullable task , NSError *error ))failure

Parameters

URLString

The URL string used to create the request URL.

parameters

The parameters to be encoded according to the client request serializer.

downloadProgress

A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue.

success

A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.

failure

A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.

Declared In

AFHTTPSessionManager.h

– HEAD:parameters:success:failure:

Creates and runs an NSURLSessionDataTask with a HEAD request.

- (nullable NSURLSessionDataTask *)HEAD:(NSString *)URLString parameters:(nullable id)parameters success:(nullable void ( ^ ) ( NSURLSessionDataTask *task ))success failure:(nullable void ( ^ ) ( NSURLSessionDataTask *_Nullable task , NSError *error ))failure

Parameters

URLString

The URL string used to create the request URL.

parameters

The parameters to be encoded according to the client request serializer.

success

A block object to be executed when the task finishes successfully. This block has no return value and takes a single arguments: the data task.

failure

A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.

Declared In

AFHTTPSessionManager.h

– POST:parameters:success:failure:

Creates and runs an NSURLSessionDataTask with a POST request.

- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString parameters:(nullable id)parameters success:(nullable void ( ^ ) ( NSURLSessionDataTask *task , id _Nullable responseObject ))success failure:(nullable void ( ^ ) ( NSURLSessionDataTask *_Nullable task , NSError *error ))failure

Parameters

URLString

The URL string used to create the request URL.

parameters

The parameters to be encoded according to the client request serializer.

success

A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.

failure

A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.

Declared In

AFHTTPSessionManager.h

– POST:parameters:progress:success:failure:

Creates and runs an NSURLSessionDataTask with a POST request.

- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString parameters:(nullable id)parameters progress:(nullable void ( ^ ) ( NSProgress *uploadProgress ))uploadProgress success:(nullable void ( ^ ) ( NSURLSessionDataTask *task , id _Nullable responseObject ))success failure:(nullable void ( ^ ) ( NSURLSessionDataTask *_Nullable task , NSError *error ))failure

Parameters

URLString

The URL string used to create the request URL.

parameters

The parameters to be encoded according to the client request serializer.

uploadProgress

A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.

success

A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.

failure

A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.

Declared In

AFHTTPSessionManager.h

– POST:parameters:constructingBodyWithBlock:success:failure:

Creates and runs an NSURLSessionDataTask with a multipart POST request.

- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString parameters:(nullable id)parameters constructingBodyWithBlock:(nullable void ( ^ ) ( id<AFMultipartFormData> formData ))block success:(nullable void ( ^ ) ( NSURLSessionDataTask *task , id _Nullable responseObject ))success failure:(nullable void ( ^ ) ( NSURLSessionDataTask *_Nullable task , NSError *error ))failure

Parameters

URLString

The URL string used to create the request URL.

parameters

The parameters to be encoded according to the client request serializer.

block

A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the AFMultipartFormData protocol.

success

A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.

failure

A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.

Declared In

AFHTTPSessionManager.h

– POST:parameters:constructingBodyWithBlock:progress:success:failure:

Creates and runs an NSURLSessionDataTask with a multipart POST request.

- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString parameters:(nullable id)parameters constructingBodyWithBlock:(nullable void ( ^ ) ( id<AFMultipartFormData> formData ))block progress:(nullable void ( ^ ) ( NSProgress *uploadProgress ))uploadProgress success:(nullable void ( ^ ) ( NSURLSessionDataTask *task , id _Nullable responseObject ))success failure:(nullable void ( ^ ) ( NSURLSessionDataTask *_Nullable task , NSError *error ))failure

Parameters

URLString

The URL string used to create the request URL.

parameters

The parameters to be encoded according to the client request serializer.

block

A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the AFMultipartFormData protocol.

uploadProgress

A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.

success

A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.

failure

A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.

Declared In

AFHTTPSessionManager.h

– PUT:parameters:success:failure:

Creates and runs an NSURLSessionDataTask with a PUT request.

- (nullable NSURLSessionDataTask *)PUT:(NSString *)URLString parameters:(nullable id)parameters success:(nullable void ( ^ ) ( NSURLSessionDataTask *task , id _Nullable responseObject ))success failure:(nullable void ( ^ ) ( NSURLSessionDataTask *_Nullable task , NSError *error ))failure

Parameters

URLString

The URL string used to create the request URL.

parameters

The parameters to be encoded according to the client request serializer.

success

A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.

failure

A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.

Declared In

AFHTTPSessionManager.h

– PATCH:parameters:success:failure:

Creates and runs an NSURLSessionDataTask with a PATCH request.

- (nullable NSURLSessionDataTask *)PATCH:(NSString *)URLString parameters:(nullable id)parameters success:(nullable void ( ^ ) ( NSURLSessionDataTask *task , id _Nullable responseObject ))success failure:(nullable void ( ^ ) ( NSURLSessionDataTask *_Nullable task , NSError *error ))failure

Parameters

URLString

The URL string used to create the request URL.

parameters

The parameters to be encoded according to the client request serializer.

success

A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.

failure

A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.

Declared In

AFHTTPSessionManager.h

– DELETE:parameters:success:failure:

Creates and runs an NSURLSessionDataTask with a DELETE request.

- (nullable NSURLSessionDataTask *)DELETE:(NSString *)URLString parameters:(nullable id)parameters success:(nullable void ( ^ ) ( NSURLSessionDataTask *task , id _Nullable responseObject ))success failure:(nullable void ( ^ ) ( NSURLSessionDataTask *_Nullable task , NSError *error ))failure

Parameters

URLString

The URL string used to create the request URL.

parameters

The parameters to be encoded according to the client request serializer.

success

A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.

failure

A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.

Declared In

AFHTTPSessionManager.h

Other Methods

– initWithSessionConfiguration:

Creates and returns a manager for a session created with the specified configuration. This is the designated initializer.

- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration

Parameters

configuration

The configuration used to create the managed session.

Return Value

A manager for a newly-created session.

Declared In

AFURLSessionManager.h

AFImageDownloader Class Reference

AFImageDownloader Class Reference

Inherits from NSObject
Declared in AFImageDownloader.h
AFImageDownloader.m

Overview

The AFImageDownloader class is responsible for downloading images in parallel on a prioritized queue. Incoming downloads are added to the front or back of the queue depending on the download prioritization. Each downloaded image is cached in the underlying NSURLCache as well as the in-memory image cache. By default, any download request with a cached image equivalent in the image cache will automatically be served the cached image representation.

  imageCache

The image cache used to store all downloaded images in. AFAutoPurgingImageCache by default.

@property (nonatomic, strong, nullable) id<AFImageRequestCache> imageCache

Declared In

AFImageDownloader.h

  sessionManager

The AFHTTPSessionManager used to download images. By default, this is configured with an AFImageResponseSerializer, and a shared NSURLCache for all image downloads.

@property (nonatomic, strong) AFHTTPSessionManager *sessionManager

Declared In

AFImageDownloader.h

  downloadPrioritizaton

Defines the order prioritization of incoming download requests being inserted into the queue. AFImageDownloadPrioritizationFIFO by default.

@property (nonatomic, assign) AFImageDownloadPrioritization downloadPrioritizaton

Declared In

AFImageDownloader.h

+ defaultInstance

The shared default instance of AFImageDownloader initialized with default values.

+ (instancetype)defaultInstance

Declared In

AFImageDownloader.h

+ defaultURLCache

Creates a default NSURLCache with common usage parameter values.

+ (NSURLCache *)defaultURLCache

Return Value

The default NSURLCache instance.

Declared In

AFImageDownloader.h

– init

Default initializer

- (instancetype)init

Return Value

An instance of AFImageDownloader initialized with default values.

Declared In

AFImageDownloader.h

– initWithSessionManager:downloadPrioritization:maximumActiveDownloads:imageCache:

Initializes the AFImageDownloader instance with the given session manager, download prioritization, maximum active download count and image cache.

- (instancetype)initWithSessionManager:(AFHTTPSessionManager *)sessionManager downloadPrioritization:(AFImageDownloadPrioritization)downloadPrioritization maximumActiveDownloads:(NSInteger)maximumActiveDownloads imageCache:(nullable id<AFImageRequestCache>)imageCache

Parameters

sessionManager

The session manager to use to download images.

downloadPrioritization

The download prioritization of the download queue.

maximumActiveDownloads

The maximum number of active downloads allowed at any given time. Recommend 4.

imageCache

The image cache used to store all downloaded images in.

Return Value

The new AFImageDownloader instance.

Declared In

AFImageDownloader.h

– downloadImageForURLRequest:success:failure:

Creates a data task using the sessionManager instance for the specified URL request.

- (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request success:(nullable void ( ^ ) ( NSURLRequest *request , NSHTTPURLResponse *_Nullable response , UIImage *responseObject ))success failure:(nullable void ( ^ ) ( NSURLRequest *request , NSHTTPURLResponse *_Nullable response , NSError *error ))failure

Parameters

request

The URL request.

success

A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be nil.

failure

A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.

Return Value

The image download receipt for the data task if available. nil if the image is stored in the cache. cache and the URL request cache policy allows the cache to be used.

Discussion

If the same data task is already in the queue or currently being downloaded, the success and failure blocks are appended to the already existing task. Once the task completes, all success or failure blocks attached to the task are executed in the order they were added.

Declared In

AFImageDownloader.h

– downloadImageForURLRequest:withReceiptID:success:failure:

Creates a data task using the sessionManager instance for the specified URL request.

- (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request withReceiptID:(NSUUID *)receiptID success:(nullable void ( ^ ) ( NSURLRequest *request , NSHTTPURLResponse *_Nullable response , UIImage *responseObject ))success failure:(nullable void ( ^ ) ( NSURLRequest *request , NSHTTPURLResponse *_Nullable response , NSError *error ))failure

Parameters

request

The URL request.

receiptID

The identifier to use for the download receipt that will be created for this request. This must be a unique identifier that does not represent any other request.

success

A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be nil.

failure

A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.

Return Value

The image download receipt for the data task if available. nil if the image is stored in the cache. cache and the URL request cache policy allows the cache to be used.

Discussion

If the same data task is already in the queue or currently being downloaded, the success and failure blocks are appended to the already existing task. Once the task completes, all success or failure blocks attached to the task are executed in the order they were added.

Declared In

AFImageDownloader.h

– cancelTaskForImageDownloadReceipt:

Cancels the data task in the receipt by removing the corresponding success and failure blocks and cancelling the data task if necessary.

- (void)cancelTaskForImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt

Parameters

imageDownloadReceipt

The image download receipt to cancel.

Discussion

If the data task is pending in the queue, it will be cancelled if no other success and failure blocks are registered with the data task. If the data task is currently executing or is already completed, the success and failure blocks are removed and will not be called when the task finishes.

Declared In

AFImageDownloader.h

AFImageResponseSerializer Class Reference

AFImageResponseSerializer Class Reference

Inherits from AFHTTPResponseSerializer : NSObject
Declared in AFURLResponseSerialization.h
AFURLResponseSerialization.m

Overview

AFImageResponseSerializer is a subclass of AFHTTPResponseSerializer that validates and decodes image responses.

By default, AFImageResponseSerializer accepts the following MIME types, which correspond to the image formats supported by UIImage or NSImage:

  • image/tiff
  • image/jpeg
  • image/gif
  • image/png
  • image/ico
  • image/x-icon
  • image/bmp
  • image/x-bmp
  • image/x-xbitmap
  • image/x-win-bitmap

Other Methods

  imageScale

The scale factor used when interpreting the image data to construct responseImage. Specifying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the size property. This is set to the value of scale of the main screen by default, which automatically scales images for retina displays, for instance.

@property (nonatomic, assign) CGFloat imageScale

Declared In

AFURLResponseSerialization.h

  automaticallyInflatesResponseImage

Whether to automatically inflate response image data for compressed formats (such as PNG or JPEG). Enabling this can significantly improve drawing performance on iOS when used with setCompletionBlockWithSuccess:failure:, as it allows a bitmap representation to be constructed in the background rather than on the main thread. YES by default.

@property (nonatomic, assign) BOOL automaticallyInflatesResponseImage

Declared In

AFURLResponseSerialization.h

Other Methods

– responseObjectForResponse:data:error:

- (id)responseObjectForResponse:(NSURLResponse *)response data:(NSData *)data error:(NSError *__autoreleasing *)error

Declared In

AFURLResponseSerialization.h