AFImageRequestOperation Class Reference
Inherits from | AFHTTPRequestOperation : AFURLConnectionOperation : NSOperation |
Declared in | AFImageRequestOperation.h |
Overview
AFImageRequestOperation
is a subclass of AFHTTPRequestOperation
for downloading an processing images.
Acceptable Content Types
By default, AFImageRequestOperation
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
Tasks
-
responseImage
An image constructed from the response data. If an error occurs during the request,
propertynil
will be returned, and theerror
property will be set to the error. -
imageScale
The scale factor used when interpreting the image data to construct
propertyresponseImage
. 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. -
+ imageRequestOperationWithRequest:success:
Creates and returns an
AFImageRequestOperation
object and sets the specified success callback. -
+ imageRequestOperationWithRequest:imageProcessingBlock:success:failure:
Creates and returns an
AFImageRequestOperation
object and sets the specified success callback.
Properties
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
Discussion
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.
Declared In
AFImageRequestOperation.h
responseImage
An image constructed from the response data. If an error occurs during the request, nil
will be returned, and the error
property will be set to the error.
@property (readonly, nonatomic, strong) UIImage *responseImage
Discussion
An image constructed from the response data. If an error occurs during the request, nil
will be returned, and the error
property will be set to the error.
Declared In
AFImageRequestOperation.h
Class Methods
imageRequestOperationWithRequest:imageProcessingBlock:success:failure:
Creates and returns an AFImageRequestOperation
object and sets the specified success callback.
+ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest imageProcessingBlock:(UIImage *( ^ ) ( UIImage *image ))imageProcessingBlock success:(void ( ^ ) ( NSURLRequest *request , NSHTTPURLResponse *response , UIImage *image ))success failure:(void ( ^ ) ( NSURLRequest *request , NSHTTPURLResponse *response , NSError *error ))failure
Parameters
- urlRequest
The request object to be loaded asynchronously during execution of the operation.
- imageProcessingBlock
A block object to be executed after the image request finishes successfully, but before the image is returned in the
success
block. This block takes a single argument, the image loaded from the response body, and returns the processed image.
- success
A block object to be executed when the request finishes successfully, with a status code in the 2xx range, and with an acceptable content type (e.g.
image/png
). This block has no return value and takes three arguments: the request object of the operation, the response for the request, and the image created from the response data.
- failure
A block object to be executed when the request finishes unsuccessfully. This block has no return value and takes three arguments: the request object of the operation, the response for the request, and the error associated with the cause for the unsuccessful operation.
Return Value
A new image request operation
Discussion
Creates and returns an AFImageRequestOperation
object and sets the specified success callback.
Declared In
AFImageRequestOperation.h
imageRequestOperationWithRequest:success:
Creates and returns an AFImageRequestOperation
object and sets the specified success callback.
+ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest success:(void ( ^ ) ( UIImage *image ))success
Parameters
- urlRequest
The request object to be loaded asynchronously during execution of the operation.
- success
A block object to be executed when the request finishes successfully. This block has no return value and takes a single arguments, the image created from the response data of the request.
Return Value
A new image request operation
Discussion
Creates and returns an AFImageRequestOperation
object and sets the specified success callback.
Declared In
AFImageRequestOperation.h