Inherits from NSOperation
Conforms to NSURLConnectionDataDelegate
NSURLConnectionDelegate
Declared in ADMDownloadOperation.h

Tasks

Accessing Run Loop Modes

  •   runLoopModes

    The run loop modes in which the operation will run on the network thread. By default, this is a single-member set containing NSRunLoopCommonModes.

    property

Getting URL Connection Information

  •   request

    The request used by the operation’s connection.

    property
  •   response

    The last response received by the operation’s connection.

    property

Getting Response Data

  •   path

    The file path where the data received during the request is saved.

    property

Accessing Streams

  •   outputStream

    The output stream that is used to write data received until the request is finished.

    property

Initializing a ADMDownloadOperation Object

Pausing / Resuming Requests

  • – pause

    Pauses the execution of the request operation.

  • – isPaused

    Whether the request operation is currently paused.

  • – resume

    Resumes the execution of the paused request operation.

Configuring Backgrounding Task Behavior

Setting Progress Callbacks

Properties

outputStream

The output stream that is used to write data received until the request is finished.

@property (nonatomic, strong) NSOutputStream *outputStream

Discussion

The output stream that is used to write data received until the request is finished.

@discussion By default, data is accumulated into a buffer that is stored into responseData upon completion of the request. When outputStream is set, the data will not be accumulated into an internal buffer, and as a result, the responseData property of the completed request will be nil. The output stream will be scheduled in the network thread runloop upon being set.

Declared In

ADMDownloadOperation.h

path

The file path where the data received during the request is saved.

@property (readonly, nonatomic, strong) NSString *path

Discussion

The file path where the data received during the request is saved.

Declared In

ADMDownloadOperation.h

request

The request used by the operation’s connection.

@property (readonly, nonatomic, strong) NSURLRequest *request

Discussion

The request used by the operation’s connection.

Declared In

ADMDownloadOperation.h

response

The last response received by the operation’s connection.

@property (readonly, nonatomic, strong) NSURLResponse *response

Discussion

The last response received by the operation’s connection.

Declared In

ADMDownloadOperation.h

runLoopModes

The run loop modes in which the operation will run on the network thread. By default, this is a single-member set containing NSRunLoopCommonModes.

@property (nonatomic, strong) NSSet *runLoopModes

Discussion

The run loop modes in which the operation will run on the network thread. By default, this is a single-member set containing NSRunLoopCommonModes.

Declared In

ADMDownloadOperation.h

Instance Methods

initWithRequest:downloadPath:

Initializes and returns a newly allocated operation object with a url connection configured with the specified url request.

- (id)initWithRequest:(NSURLRequest *)urlRequest downloadPath:(NSString *)path

Parameters

urlRequest

The request object to be used by the operation connection.

path

The download path where the recieved data object will be saved.

@discussion This is the designated initializer.

Discussion

Initializes and returns a newly allocated operation object with a url connection configured with the specified url request.

Declared In

ADMDownloadOperation.h

isPaused

Whether the request operation is currently paused.

- (BOOL)isPaused

Return Value

YES if the operation is currently paused, otherwise NO.

Discussion

Whether the request operation is currently paused.

Declared In

ADMDownloadOperation.h

pause

Pauses the execution of the request operation.

- (void)pause

Discussion

Pauses the execution of the request operation.

@discussion A paused operation returns NO for -isReady, -isExecuting, and -isFinished. As such, it will remain in an NSOperationQueue until it is either cancelled or resumed. Pausing a finished, cancelled, or paused operation has no effect.

Declared In

ADMDownloadOperation.h

resume

Resumes the execution of the paused request operation.

- (void)resume

Discussion

Resumes the execution of the paused request operation.

@discussion Pause/Resume behavior varies depending on the underlying implementation for the operation class. In its base implementation, resuming a paused requests restarts the original request. However, since HTTP defines a specification for how to request a specific content range, ADMDownloadOperation will resume downloading the request from where it left off, instead of restarting the original request.

Declared In

ADMDownloadOperation.h

setDownloadProgressBlock:

Sets a callback to be called when an undetermined number of bytes have been downloaded from the server.

- (void)setDownloadProgressBlock:(void ( ^ ) ( float percentage ))block

Parameters

block

A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes one argument: the percentage of the total bytes read during the request, as initially determined by the expected content size of the NSHTTPURLResponse object. This block may be called multiple times, and will execute on the main thread.

Discussion

Sets a callback to be called when an undetermined number of bytes have been downloaded from the server.

Declared In

ADMDownloadOperation.h

setShouldExecuteAsBackgroundTaskWithExpirationHandler:

Specifies that the operation should continue execution after the app has entered the background, and the expiration handler for that background task.

- (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void ( ^ ) ( void ))handler

Parameters

handler

A handler to be called shortly before the application’s remaining background time reaches 0. The handler is wrapped in a block that cancels the operation, and cleans up and marks the end of execution, unlike the handler parameter in UIApplication -beginBackgroundTaskWithExpirationHandler:, which expects this to be done in the handler itself. The handler is called synchronously on the main thread, thus blocking the application’s suspension momentarily while the application is notified.

Discussion

Specifies that the operation should continue execution after the app has entered the background, and the expiration handler for that background task.

Declared In

ADMDownloadOperation.h