ADMDownloadOperation Class Reference
| Inherits from | NSOperation |
| Conforms to | NSURLConnectionDataDelegate NSURLConnectionDelegate |
| Declared in | ADMDownloadOperation.h |
Tasks
Accessing Run Loop Modes
-
runLoopModesThe run loop modes in which the operation will run on the network thread. By default, this is a single-member set containing
propertyNSRunLoopCommonModes.
Getting URL Connection Information
-
requestThe request used by the operation’s connection.
property -
responseThe last response received by the operation’s connection.
property
Getting Response Data
-
pathThe file path where the data received during the request is saved.
property
Accessing Streams
-
outputStreamThe output stream that is used to write data received until the request is finished.
property
Initializing a ADMDownloadOperation Object
-
– initWithRequest:downloadPath:Initializes and returns a newly allocated operation object with a url connection configured with the specified url request.
Pausing / Resuming Requests
-
– pausePauses the execution of the request operation.
-
– isPausedWhether the request operation is currently paused.
-
– resumeResumes the execution of the paused request operation.
Configuring Backgrounding Task Behavior
-
– setShouldExecuteAsBackgroundTaskWithExpirationHandler:Specifies that the operation should continue execution after the app has entered the background, and the expiration handler for that background task.
Setting Progress Callbacks
-
– setDownloadProgressBlock:Sets a callback to be called when an undetermined number of bytes have been downloaded from the server.
Properties
outputStream
The output stream that is used to write data received until the request is finished.
@property (nonatomic, strong) NSOutputStream *outputStreamDiscussion
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.hpath
The file path where the data received during the request is saved.
@property (readonly, nonatomic, strong) NSString *pathDiscussion
The file path where the data received during the request is saved.
Declared In
ADMDownloadOperation.hrequest
The request used by the operation’s connection.
@property (readonly, nonatomic, strong) NSURLRequest *requestDiscussion
The request used by the operation’s connection.
Declared In
ADMDownloadOperation.hresponse
The last response received by the operation’s connection.
@property (readonly, nonatomic, strong) NSURLResponse *responseDiscussion
The last response received by the operation’s connection.
Declared In
ADMDownloadOperation.hrunLoopModes
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 *runLoopModesDiscussion
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.hInstance 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 *)pathParameters
- 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.hisPaused
Whether the request operation is currently paused.
- (BOOL)isPausedReturn Value
YES if the operation is currently paused, otherwise NO.
Discussion
Whether the request operation is currently paused.
Declared In
ADMDownloadOperation.hpause
Pauses the execution of the request operation.
- (void)pauseDiscussion
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.hresume
Resumes the execution of the paused request operation.
- (void)resumeDiscussion
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.hsetDownloadProgressBlock:
Sets a callback to be called when an undetermined number of bytes have been downloaded from the server.
- (void)setDownloadProgressBlock:(void ( ^ ) ( float percentage ))blockParameters
- 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
NSHTTPURLResponseobject. 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.hsetShouldExecuteAsBackgroundTaskWithExpirationHandler:
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 ))handlerParameters
- 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
handlerparameter inUIApplication -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