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
-
didReceiveResponseHandlerCalled by
propertyNSURLSessionDataDelegatemethodURLSession:dataTask:didReceiveResponse:completionHandler:. -
didReceiveDataHandlerCalled by
propertyNSURLSessionDataDelegatemethodURLSession:dataTask:didReceiveData:. -
progressHandlerCalled by
propertyNSURLSessionDataDelegatemethodURLSession:dataTask:didReceiveData: -
willCacheResponseHandlerCalled by
propertyNSURLSessionDataDelegatemethodURLSession:dataTask:willCacheResponse:completionHandler: -
didBecomeDownloadTaskHandlerCalled by
propertyNSURLSessionDataDelegatemethodURLSession:dataTask:didBecomeDownloadTask:
Other Methods
-
– initWithSession:request:Create NetworkTaskOperation
Properties
didBecomeDownloadTaskHandler
Called by NSURLSessionDataDelegate method URLSession:dataTask:didBecomeDownloadTask:
@property (nonatomic, copy) DidBecomeDownloadTaskHandler didBecomeDownloadTaskHandlerDiscussion
Uses the following typdef:
typedef void(^DidBecomeDownloadTaskHandler)(NetworkDataTaskOperation *operation,
NSURLSessionDownloadTask *downloadTask);
Declared In
NetworkDataTaskOperation.hdidReceiveDataHandler
Called by NSURLSessionDataDelegate method URLSession:dataTask:didReceiveData:.
@property (nonatomic, copy) DidReceiveDataHandler didReceiveDataHandlerDiscussion
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.hdidReceiveResponseHandler
Called by NSURLSessionDataDelegate method URLSession:dataTask:didReceiveResponse:completionHandler:.
@property (nonatomic, copy) DidReceiveResponseHandler didReceiveResponseHandlerDiscussion
Uses the following typdef:
typedef void(^DidReceiveResponseHandler)(NetworkDataTaskOperation *operation,
NSURLResponse *response,
void(^completionHandler)(NSURLSessionResponseDisposition disposition));
Declared In
NetworkDataTaskOperation.hprogressHandler
Called by NSURLSessionDataDelegate method URLSession:dataTask:didReceiveData:
@property (nonatomic, copy) ProgressHandler progressHandlerDiscussion
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.hwillCacheResponseHandler
Called by NSURLSessionDataDelegate method URLSession:dataTask:willCacheResponse:completionHandler:
@property (nonatomic, copy) WillCacheResponseHandler willCacheResponseHandlerDiscussion
Uses the following typedef:
typedef void(^WillCacheResponseHandler)(NetworkDataTaskOperation *operation,
NSCachedURLResponse *proposedResponse,
void(^completionHandler)(NSCachedURLResponse *cachedResponse));
Declared In
NetworkDataTaskOperation.hInstance Methods
initWithSession:request:
Create NetworkTaskOperation
- (instancetype)initWithSession:(NSURLSession *)session request:(NSURLRequest *)requestParameters
- session
The
NSURLSessionfor which the task operation should be created.
- request
The
NSURLRequestfor the task operation.
Return Value
Returns NetworkTaskOperation.
Declared In
NetworkTaskOperation.h