NetworkDataTaskOperation Class Reference
Inherits from | NetworkTaskOperation : NSOperation |
Conforms to | NSURLSessionDataDelegate |
Declared in | NetworkDataTaskOperation.h NetworkDataTaskOperation.m |
Overview
Operation that wraps delegate-based NSURLSessionDataDask.
This is a NetworkTaskOperation
subclass instantiated by NetworkManager
method
dataOperationWithRequest:progressHandler:completionHandler:
.
This implements the NSURLSessionTaskDelegate
methods, which the
NetworkManager
will invoke as it (the actual task delegate)
receives its delegate calls.
Tasks
Properties
-
didReceiveResponseHandler
Called by
propertyNSURLSessionDataDelegate
methodURLSession:dataTask:didReceiveResponse:completionHandler:
. -
didReceiveDataHandler
Called by
propertyNSURLSessionDataDelegate
methodURLSession:dataTask:didReceiveData:
. -
progressHandler
Called by
propertyNSURLSessionDataDelegate
methodURLSession:dataTask:didReceiveData:
-
willCacheResponseHandler
Called by
propertyNSURLSessionDataDelegate
methodURLSession:dataTask:willCacheResponse:completionHandler:
-
didBecomeDownloadTaskHandler
Called by
propertyNSURLSessionDataDelegate
methodURLSession:dataTask:didBecomeDownloadTask:
Other Methods
-
– initWithSession:request:
Create NetworkTaskOperation
Properties
didBecomeDownloadTaskHandler
Called by NSURLSessionDataDelegate
method URLSession:dataTask:didBecomeDownloadTask:
@property (nonatomic, copy) DidBecomeDownloadTaskHandler didBecomeDownloadTaskHandler
Discussion
Uses the following typdef:
typedef void(^DidBecomeDownloadTaskHandler)(NetworkDataTaskOperation *operation,
NSURLSessionDownloadTask *downloadTask);
Declared In
NetworkDataTaskOperation.h
didReceiveDataHandler
Called by NSURLSessionDataDelegate
method URLSession:dataTask:didReceiveData:
.
@property (nonatomic, copy) DidReceiveDataHandler didReceiveDataHandler
Discussion
Use this block if you do not want the NetworkDataTaskOperation
to build a NSData
object
with the entire response, but rather if you’re going to handle the data as it comes in yourself
(e.g. you have your own streaming method or are going to be processing the response as it comes
in, rather than waiting for the entire response).
Uses the following typedef:
typedef void(^DidReceiveDataHandler)(NetworkDataTaskOperation *operation,
NSData *data,
long long totalBytesExpected,
long long bytesReceived);
Note: The totalBytesExpected
parameter of this block is provided by the server, and as such, it is not entirely reliable. Also note that if it could not be determined, totalBytesExpected
may be reported as -1.
See Also
Declared In
NetworkDataTaskOperation.h
didReceiveResponseHandler
Called by NSURLSessionDataDelegate
method URLSession:dataTask:didReceiveResponse:completionHandler:
.
@property (nonatomic, copy) DidReceiveResponseHandler didReceiveResponseHandler
Discussion
Uses the following typdef:
typedef void(^DidReceiveResponseHandler)(NetworkDataTaskOperation *operation,
NSURLResponse *response,
void(^completionHandler)(NSURLSessionResponseDisposition disposition));
Declared In
NetworkDataTaskOperation.h
progressHandler
Called by NSURLSessionDataDelegate
method URLSession:dataTask:didReceiveData:
@property (nonatomic, copy) ProgressHandler progressHandler
Discussion
Use this block if you do want the NetworkDataTaskOperation
to build a NSData
object
with the entire response, but simply want to be notified of its progress.
Uses the following typedef:
typedef void(^ProgressHandler)(NetworkDataTaskOperation *operation,
long long totalBytesExpected,
long long bytesReceived);
Note: The totalBytesExpected
parameter of this block is provided by the server, and as such, it is not entirely reliable. Also note that if it could not be determined, totalBytesExpected
may be reported as -1.
See Also
Declared In
NetworkDataTaskOperation.h
willCacheResponseHandler
Called by NSURLSessionDataDelegate
method URLSession:dataTask:willCacheResponse:completionHandler:
@property (nonatomic, copy) WillCacheResponseHandler willCacheResponseHandler
Discussion
Uses the following typedef:
typedef void(^WillCacheResponseHandler)(NetworkDataTaskOperation *operation,
NSCachedURLResponse *proposedResponse,
void(^completionHandler)(NSCachedURLResponse *cachedResponse));
Declared In
NetworkDataTaskOperation.h
Instance Methods
initWithSession:request:
Create NetworkTaskOperation
- (instancetype)initWithSession:(NSURLSession *)session request:(NSURLRequest *)request
Parameters
- session
The
NSURLSession
for which the task operation should be created.
- request
The
NSURLRequest
for the task operation.
Return Value
Returns NetworkTaskOperation.
Declared In
NetworkTaskOperation.h