MKNetworkOperation Class Reference
| Inherits from | NSOperation |
| Conforms to | NSURLConnectionDataDelegate |
| Declared in | MKNetworkOperation.h MKNetworkOperation.m |
Tasks
-
urlproperty -
readonlyRequestproperty -
readonlyResponseproperty -
readonlyPostDictionaryproperty -
HTTPMethodproperty -
HTTPStatusCodeproperty -
postDataEncodingproperty -
– setCustomPostDataEncodingHandler:forType: -
stringEncodingproperty -
freezableproperty -
errorproperty -
shouldCacheResponseEvenIfProtocolIsHTTPSproperty -
shouldNotCacheResponseproperty -
shouldContinueWithInvalidCertificateproperty -
shouldSendAcceptLanguageHeaderproperty -
cacheHeadersproperty -
– setUsername:password: -
– setUsername:password:basicAuth: -
clientCertificateproperty -
clientCertificatePasswordproperty -
authHandlerproperty -
operationStateChangedHandlerproperty -
credentialPersistenceproperty -
localNotificationproperty -
shouldShowLocalNotificationOnErrorproperty -
– addParams: -
– addHeader:withValue: -
– addHeaders: -
– setHeader:withValue: -
– setAuthorizationHeaderValue:forAuthType: -
– addFile:forKey: -
– addFile:forKey:mimeType: -
– addData:forKey: -
– addData:forKey:mimeType:fileName: -
– onCompletion:onError: -
– addCompletionHandler:errorHandler: -
– onNotModified: -
– onUploadProgressChanged: -
– onDownloadProgressChanged: -
– setUploadStream: -
– addDownloadStream: -
– isCachedResponse -
– responseData -
– responseString -
– curlCommandLineString -
– responseStringWithEncoding: -
– responseImage -
– responseJSON -
– responseJSONWithCompletionHandler: -
– responseJSONWithOptions:completionHandler: -
– operationSucceeded -
– operationFailedWithError: -
– copyForRetry
Properties
HTTPMethod
The internal request object’s method type @property HTTPMethod
@property (nonatomic, copy, readonly) NSString *HTTPMethodDeclared In
MKNetworkOperation.hHTTPStatusCode
The internal response object’s status code @property HTTPStatusCode
@property (nonatomic, assign, readonly) NSInteger HTTPStatusCodeDeclared In
MKNetworkOperation.hauthHandler
Custom authentication handler @property authHandler
@property (nonatomic, copy) MKNKAuthBlock authHandlerDeclared In
MKNetworkOperation.hcacheHeaders
Cache headers of the response @property cacheHeaders
@property (strong, nonatomic) NSMutableDictionary *cacheHeadersDeclared In
MKNetworkOperation.hclientCertificate
Authentication methods (Client Certificate) @property clientCertificate
@property (copy, nonatomic) NSString *clientCertificateDeclared In
MKNetworkOperation.hclientCertificatePassword
Authentication methods (Password for the Client Certificate) @property clientCertificatePassword
@property (copy, nonatomic) NSString *clientCertificatePasswordDeclared In
MKNetworkOperation.hcredentialPersistence
controls persistence of authentication credentials @property credentialPersistence
@property (nonatomic, assign) NSURLCredentialPersistence credentialPersistenceDeclared In
MKNetworkOperation.herror
Error object @property error
@property (nonatomic, readonly, strong) NSError *errorDeclared In
MKNetworkOperation.hfreezable
Freezable request @property freezable
@property (nonatomic, assign) BOOL freezableDeclared In
MKNetworkOperation.hlocalNotification
notification that has to be shown when an error occurs and the app is in background @property localNotification
@property (nonatomic, strong) UILocalNotification *localNotificationDeclared In
MKNetworkOperation.hoperationStateChangedHandler
Handler that you implement to monitor reachability changes @property operationStateChangedHandler
@property (copy, nonatomic) void ( ^ ) ( MKNetworkOperationState newState ) operationStateChangedHandlerDeclared In
MKNetworkOperation.hpostDataEncoding
Post Data Encoding Type Property @property postDataEncoding
@property (nonatomic, assign) MKNKPostDataEncodingType postDataEncodingDeclared In
MKNetworkOperation.hreadonlyPostDictionary
The internal HTTP Post data values @property readonlyPostDictionary
@property (nonatomic, copy, readonly) NSDictionary *readonlyPostDictionaryDeclared In
MKNetworkOperation.hreadonlyRequest
The internal request object @property readonlyRequest
@property (nonatomic, strong, readonly) NSURLRequest *readonlyRequestDeclared In
MKNetworkOperation.hreadonlyResponse
The internal HTTP Response Object @property readonlyResponse
@property (nonatomic, strong, readonly) NSHTTPURLResponse *readonlyResponseDeclared In
MKNetworkOperation.hshouldCacheResponseEvenIfProtocolIsHTTPS
Boolean variable that states whether the operation’s response should be cached despite coming from a secured source @property shouldCacheEvenIfProtocolIsHTTPS
@property (nonatomic, assign) BOOL shouldCacheResponseEvenIfProtocolIsHTTPSDeclared In
MKNetworkOperation.hshouldContinueWithInvalidCertificate
Boolean variable that states whether the operation should continue if the certificate is invalid. @property shouldContinueWithInvalidCertificate
@property (nonatomic, assign) BOOL shouldContinueWithInvalidCertificateDeclared In
MKNetworkOperation.hshouldNotCacheResponse
Boolean variable that states whether the operation’s response should be cached @property shouldNotCacheResponse
@property (nonatomic, assign) BOOL shouldNotCacheResponseDeclared In
MKNetworkOperation.hshouldSendAcceptLanguageHeader
Boolean variable that states whether the request should automatically include an Accept-Language header. @property shouldSendAcceptLanguageHeader
@property (nonatomic, assign) BOOL shouldSendAcceptLanguageHeaderDeclared In
MKNetworkOperation.hshouldShowLocalNotificationOnError
- @abstract Shows a local notification when an error occurs
- @property shouldShowLocalNotificationOnError *
- @discussion
- The default value NO. No notification is shown when an error occurs.
- When set to YES, MKNetworkKit shows the NSError localizedDescription text as a notification when the app is in background and the network operation ended in error.
- To customize the local notification text, use the property localNotification
@property (nonatomic, assign) BOOL shouldShowLocalNotificationOnErrorDiscussion
- @abstract Shows a local notification when an error occurs
- @property shouldShowLocalNotificationOnError *
- @discussion
- The default value NO. No notification is shown when an error occurs.
- When set to YES, MKNetworkKit shows the NSError localizedDescription text as a notification when the app is in background and the network operation ended in error.
To customize the local notification text, use the property localNotification
@seealso
- localNotification
Declared In
MKNetworkOperation.hInstance Methods
addCompletionHandler:errorHandler:
adds a block Handler for completion and error
- (void)addCompletionHandler:(MKNKResponseBlock)response errorHandler:(MKNKResponseErrorBlock)errorDeclared In
MKNetworkOperation.haddData:forKey:
Attaches a resource to the request from a NSData pointer
- (void)addData:(NSData *)data forKey:(NSString *)keyDeclared In
MKNetworkOperation.haddData:forKey:mimeType:fileName:
Attaches a resource to the request from a NSData pointer and allows you to specify a mime-type
- (void)addData:(NSData *)data forKey:(NSString *)key mimeType:(NSString *)mimeType fileName:(NSString *)fileNameDeclared In
MKNetworkOperation.haddDownloadStream:
Downloads a resource directly to a file or any output stream
- (void)addDownloadStream:(NSOutputStream *)outputStreamDeclared In
MKNetworkOperation.haddFile:forKey:
Attaches a file to the request
- (void)addFile:(NSString *)filePath forKey:(NSString *)keyDeclared In
MKNetworkOperation.haddFile:forKey:mimeType:
Attaches a file to the request and allows you to specify a mime-type
- (void)addFile:(NSString *)filePath forKey:(NSString *)key mimeType:(NSString *)mimeTypeDeclared In
MKNetworkOperation.haddHeader:withValue:
Add additional header
- (void)addHeader:(NSString *)key withValue:(NSString *)valueDiscussion
Add a single additional header. See addHeaders for a full discussion.
Declared In
MKNetworkOperation.haddHeaders:
Add additional header parameters
- (void)addHeaders:(NSDictionary *)headersDictionaryDeclared In
MKNetworkOperation.haddParams:
Add additional POST/GET parameters to your request
- (void)addParams:(NSDictionary *)paramsDictionaryDeclared In
MKNetworkOperation.hcopyForRetry
Copy this MKNetworkOperation, with the intention of retrying the call.
- (instancetype)copyForRetryDiscussion
This means that the request parameters and callbacks are all preserved, but anything related to an ongoing request is discarded, so that a new request with the same configuration can be made.
Declared In
MKNetworkOperation.hcurlCommandLineString
Helper method to print the request as a cURL command
- (NSString *)curlCommandLineStringDeclared In
MKNetworkOperation.hisCachedResponse
Helper method to check if the response is from cache
- (BOOL)isCachedResponseDeclared In
MKNetworkOperation.honCompletion:onError:
Block Handler for completion and error
- (void)onCompletion:(MKNKResponseBlock)response onError:(MKNKErrorBlock)errorDeclared In
MKNetworkOperation.honDownloadProgressChanged:
Block Handler for tracking download progress
- (void)onDownloadProgressChanged:(MKNKProgressBlock)downloadProgressBlockDeclared In
MKNetworkOperation.honNotModified:
Block Handler for tracking 304 not modified state
- (void)onNotModified:(MKNKVoidBlock)notModifiedBlockDeclared In
MKNetworkOperation.honUploadProgressChanged:
Block Handler for tracking upload progress
- (void)onUploadProgressChanged:(MKNKProgressBlock)uploadProgressBlockDeclared In
MKNetworkOperation.hoperationFailedWithError:
Overridable custom method where you can add your custom business logic error handling
- (void)operationFailedWithError:(NSError *)errorDeclared In
MKNetworkOperation.hoperationSucceeded
Overridable custom method where you can add your custom business logic error handling
- (void)operationSucceededDeclared In
MKNetworkOperation.hresponseData
Helper method to retrieve the contents
- (NSData *)responseDataDeclared In
MKNetworkOperation.hresponseImage
Helper method to retrieve the contents as a UIImage
- (UIImage *)responseImageDeclared In
MKNetworkOperation.hresponseJSON
- @abstract Helper method to retrieve the contents as a NSDictionary or NSArray depending on the JSON contents *
- @discussion
- This method is used for accessing the downloaded data as a NSDictionary or an NSArray. If the operation is still in progress, the method returns nil. If the response is not a valid JSON, this method returns nil. *
- @seealso
- responseJSONWithCompletionHandler:
- (id)responseJSONDiscussion
- @abstract Helper method to retrieve the contents as a NSDictionary or NSArray depending on the JSON contents *
- @discussion
- This method is used for accessing the downloaded data as a NSDictionary or an NSArray. If the operation is still in progress, the method returns nil. If the response is not a valid JSON, this method returns nil. *
- @seealso
@availability
- iOS 5 and above or Mac OS 10.7 and above
Declared In
MKNetworkOperation.hresponseJSONWithCompletionHandler:
Helper method to retrieve the contents as a NSDictionary or NSArray depending on the JSON contents in the background
- (void)responseJSONWithCompletionHandler:(void ( ^ ) ( id jsonObject ))jsonDecompressionHandlerSee Also
also - responseJSON - responseJSONWithOptions:completionHandler:
@availability iOS 5 and above or Mac OS 10.7 and above
Declared In
MKNetworkOperation.hresponseJSONWithOptions:completionHandler:
Helper method to retrieve the contents as a NSDictionary or NSArray depending on the JSON contents in the background
- (void)responseJSONWithOptions:(NSJSONReadingOptions)options completionHandler:(void ( ^ ) ( id jsonObject ))jsonDecompressionHandlerSee Also
also - responseJSON - responseJSONWithCompletionHandler:
@availability iOS 5 and above or Mac OS 10.7 and above
Declared In
MKNetworkOperation.hresponseString
Helper method to retrieve the contents as a NSString
- (NSString *)responseStringDeclared In
MKNetworkOperation.hresponseStringWithEncoding:
Helper method to retrieve the contents as a NSString encoded using a specific string encoding
- (NSString *)responseStringWithEncoding:(NSStringEncoding)encodingDeclared In
MKNetworkOperation.hsetAuthorizationHeaderValue:forAuthType:
Sets the authorization header after prefixing it with a given auth type
- (void)setAuthorizationHeaderValue:(NSString *)token forAuthType:(NSString *)authTypeDeclared In
MKNetworkOperation.hsetCustomPostDataEncodingHandler:forType:
Set a customized Post Data Encoding Handler for a given HTTP Content Type
- (void)setCustomPostDataEncodingHandler:(MKNKEncodingBlock)postDataEncodingHandler forType:(NSString *)contentTypeDeclared In
MKNetworkOperation.hsetHeader:withValue:
Set a header, overwriting any value already set.
- (void)setHeader:(NSString *)key withValue:(NSString *)valueDiscussion
addHeader will append the value to any header already set. If you want to overwrite that value, then use setHeader instead.
Declared In
MKNetworkOperation.hsetUploadStream:
Uploads a resource from a stream
- (void)setUploadStream:(NSInputStream *)inputStreamDeclared In
MKNetworkOperation.h