MKNetworkOperation Class Reference
Inherits from | NSOperation |
Conforms to | NSURLConnectionDataDelegate |
Declared in | MKNetworkOperation.h MKNetworkOperation.m |
Tasks
-
url
property -
readonlyRequest
property -
readonlyResponse
property -
readonlyPostDictionary
property -
HTTPMethod
property -
HTTPStatusCode
property -
postDataEncoding
property -
– setCustomPostDataEncodingHandler:forType:
-
stringEncoding
property -
freezable
property -
error
property -
shouldCacheResponseEvenIfProtocolIsHTTPS
property -
shouldNotCacheResponse
property -
shouldContinueWithInvalidCertificate
property -
shouldSendAcceptLanguageHeader
property -
cacheHeaders
property -
– setUsername:password:
-
– setUsername:password:basicAuth:
-
clientCertificate
property -
clientCertificatePassword
property -
authHandler
property -
operationStateChangedHandler
property -
credentialPersistence
property -
localNotification
property -
shouldShowLocalNotificationOnError
property -
– 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 *HTTPMethod
Declared In
MKNetworkOperation.h
HTTPStatusCode
The internal response object’s status code @property HTTPStatusCode
@property (nonatomic, assign, readonly) NSInteger HTTPStatusCode
Declared In
MKNetworkOperation.h
authHandler
Custom authentication handler @property authHandler
@property (nonatomic, copy) MKNKAuthBlock authHandler
Declared In
MKNetworkOperation.h
cacheHeaders
Cache headers of the response @property cacheHeaders
@property (strong, nonatomic) NSMutableDictionary *cacheHeaders
Declared In
MKNetworkOperation.h
clientCertificate
Authentication methods (Client Certificate) @property clientCertificate
@property (copy, nonatomic) NSString *clientCertificate
Declared In
MKNetworkOperation.h
clientCertificatePassword
Authentication methods (Password for the Client Certificate) @property clientCertificatePassword
@property (copy, nonatomic) NSString *clientCertificatePassword
Declared In
MKNetworkOperation.h
credentialPersistence
controls persistence of authentication credentials @property credentialPersistence
@property (nonatomic, assign) NSURLCredentialPersistence credentialPersistence
Declared In
MKNetworkOperation.h
error
Error object @property error
@property (nonatomic, readonly, strong) NSError *error
Declared In
MKNetworkOperation.h
freezable
Freezable request @property freezable
@property (nonatomic, assign) BOOL freezable
Declared In
MKNetworkOperation.h
localNotification
notification that has to be shown when an error occurs and the app is in background @property localNotification
@property (nonatomic, strong) UILocalNotification *localNotification
Declared In
MKNetworkOperation.h
operationStateChangedHandler
Handler that you implement to monitor reachability changes @property operationStateChangedHandler
@property (copy, nonatomic) void ( ^ ) ( MKNetworkOperationState newState ) operationStateChangedHandler
Declared In
MKNetworkOperation.h
postDataEncoding
Post Data Encoding Type Property @property postDataEncoding
@property (nonatomic, assign) MKNKPostDataEncodingType postDataEncoding
Declared In
MKNetworkOperation.h
readonlyPostDictionary
The internal HTTP Post data values @property readonlyPostDictionary
@property (nonatomic, copy, readonly) NSDictionary *readonlyPostDictionary
Declared In
MKNetworkOperation.h
readonlyRequest
The internal request object @property readonlyRequest
@property (nonatomic, strong, readonly) NSURLRequest *readonlyRequest
Declared In
MKNetworkOperation.h
readonlyResponse
The internal HTTP Response Object @property readonlyResponse
@property (nonatomic, strong, readonly) NSHTTPURLResponse *readonlyResponse
Declared In
MKNetworkOperation.h
shouldCacheResponseEvenIfProtocolIsHTTPS
Boolean variable that states whether the operation’s response should be cached despite coming from a secured source @property shouldCacheEvenIfProtocolIsHTTPS
@property (nonatomic, assign) BOOL shouldCacheResponseEvenIfProtocolIsHTTPS
Declared In
MKNetworkOperation.h
shouldContinueWithInvalidCertificate
Boolean variable that states whether the operation should continue if the certificate is invalid. @property shouldContinueWithInvalidCertificate
@property (nonatomic, assign) BOOL shouldContinueWithInvalidCertificate
Declared In
MKNetworkOperation.h
shouldNotCacheResponse
Boolean variable that states whether the operation’s response should be cached @property shouldNotCacheResponse
@property (nonatomic, assign) BOOL shouldNotCacheResponse
Declared In
MKNetworkOperation.h
shouldSendAcceptLanguageHeader
Boolean variable that states whether the request should automatically include an Accept-Language header. @property shouldSendAcceptLanguageHeader
@property (nonatomic, assign) BOOL shouldSendAcceptLanguageHeader
Declared In
MKNetworkOperation.h
shouldShowLocalNotificationOnError
- @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 shouldShowLocalNotificationOnError
Discussion
- @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.h
Instance Methods
addCompletionHandler:errorHandler:
adds a block Handler for completion and error
- (void)addCompletionHandler:(MKNKResponseBlock)response errorHandler:(MKNKResponseErrorBlock)error
Declared In
MKNetworkOperation.h
addData:forKey:
Attaches a resource to the request from a NSData pointer
- (void)addData:(NSData *)data forKey:(NSString *)key
Declared In
MKNetworkOperation.h
addData: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 *)fileName
Declared In
MKNetworkOperation.h
addDownloadStream:
Downloads a resource directly to a file or any output stream
- (void)addDownloadStream:(NSOutputStream *)outputStream
Declared In
MKNetworkOperation.h
addFile:forKey:
Attaches a file to the request
- (void)addFile:(NSString *)filePath forKey:(NSString *)key
Declared In
MKNetworkOperation.h
addFile: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 *)mimeType
Declared In
MKNetworkOperation.h
addHeader:withValue:
Add additional header
- (void)addHeader:(NSString *)key withValue:(NSString *)value
Discussion
Add a single additional header. See addHeaders for a full discussion.
Declared In
MKNetworkOperation.h
addHeaders:
Add additional header parameters
- (void)addHeaders:(NSDictionary *)headersDictionary
Declared In
MKNetworkOperation.h
addParams:
Add additional POST/GET parameters to your request
- (void)addParams:(NSDictionary *)paramsDictionary
Declared In
MKNetworkOperation.h
copyForRetry
Copy this MKNetworkOperation, with the intention of retrying the call.
- (instancetype)copyForRetry
Discussion
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.h
curlCommandLineString
Helper method to print the request as a cURL command
- (NSString *)curlCommandLineString
Declared In
MKNetworkOperation.h
isCachedResponse
Helper method to check if the response is from cache
- (BOOL)isCachedResponse
Declared In
MKNetworkOperation.h
onCompletion:onError:
Block Handler for completion and error
- (void)onCompletion:(MKNKResponseBlock)response onError:(MKNKErrorBlock)error
Declared In
MKNetworkOperation.h
onDownloadProgressChanged:
Block Handler for tracking download progress
- (void)onDownloadProgressChanged:(MKNKProgressBlock)downloadProgressBlock
Declared In
MKNetworkOperation.h
onNotModified:
Block Handler for tracking 304 not modified state
- (void)onNotModified:(MKNKVoidBlock)notModifiedBlock
Declared In
MKNetworkOperation.h
onUploadProgressChanged:
Block Handler for tracking upload progress
- (void)onUploadProgressChanged:(MKNKProgressBlock)uploadProgressBlock
Declared In
MKNetworkOperation.h
operationFailedWithError:
Overridable custom method where you can add your custom business logic error handling
- (void)operationFailedWithError:(NSError *)error
Declared In
MKNetworkOperation.h
operationSucceeded
Overridable custom method where you can add your custom business logic error handling
- (void)operationSucceeded
Declared In
MKNetworkOperation.h
responseData
Helper method to retrieve the contents
- (NSData *)responseData
Declared In
MKNetworkOperation.h
responseImage
Helper method to retrieve the contents as a UIImage
- (UIImage *)responseImage
Declared In
MKNetworkOperation.h
responseJSON
- @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)responseJSON
Discussion
- @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.h
responseJSONWithCompletionHandler:
Helper method to retrieve the contents as a NSDictionary or NSArray depending on the JSON contents in the background
- (void)responseJSONWithCompletionHandler:(void ( ^ ) ( id jsonObject ))jsonDecompressionHandler
See Also
also - responseJSON - responseJSONWithOptions:completionHandler:
@availability iOS 5 and above or Mac OS 10.7 and above
Declared In
MKNetworkOperation.h
responseJSONWithOptions: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 ))jsonDecompressionHandler
See Also
also - responseJSON - responseJSONWithCompletionHandler:
@availability iOS 5 and above or Mac OS 10.7 and above
Declared In
MKNetworkOperation.h
responseString
Helper method to retrieve the contents as a NSString
- (NSString *)responseString
Declared In
MKNetworkOperation.h
responseStringWithEncoding:
Helper method to retrieve the contents as a NSString encoded using a specific string encoding
- (NSString *)responseStringWithEncoding:(NSStringEncoding)encoding
Declared In
MKNetworkOperation.h
setAuthorizationHeaderValue:forAuthType:
Sets the authorization header after prefixing it with a given auth type
- (void)setAuthorizationHeaderValue:(NSString *)token forAuthType:(NSString *)authType
Declared In
MKNetworkOperation.h
setCustomPostDataEncodingHandler:forType:
Set a customized Post Data Encoding Handler for a given HTTP Content Type
- (void)setCustomPostDataEncodingHandler:(MKNKEncodingBlock)postDataEncodingHandler forType:(NSString *)contentType
Declared In
MKNetworkOperation.h
setHeader:withValue:
Set a header, overwriting any value already set.
- (void)setHeader:(NSString *)key withValue:(NSString *)value
Discussion
addHeader will append the value to any header already set. If you want to overwrite that value, then use setHeader instead.
Declared In
MKNetworkOperation.h
setUploadStream:
Uploads a resource from a stream
- (void)setUploadStream:(NSInputStream *)inputStream
Declared In
MKNetworkOperation.h