I'm new to MKNetworkKit
, but I've been able to add it to my project and it's perfectly working except when dealing with reachability changes.
Here is the situation:
- I disable WiFi and run the app.
- Even without reachability, I request (using
POST
) some data by creating aMKNetworkOperation
from myMKNetworkEngine
subclass. Right before requesting data, the operation is set as freezable (as per Mugunth Kumar's doc). - After enabling WiFi,
checkAndRestoreFrozenOperations
inMKNetworkEngine
is called and it detects there is one pending operation (the one created without reachability), which tries to enqueue. - After that, my
onCompletion
block is never called.
Is there anything I don't understand about freezing operations + reachability in MKNetworkKit
? Does freeze only work for operations where reachability changes after a request has started? Or should I implement my own reachability changed block?
Here is the code in my MKNetworkEngine
subclass that creates the operation and starts the request. Note that irrelevant code has been suppressed.
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObject:@"value" forKey:@"param"];
MKNetworkOperation *op = [self operationWithPath:MYPATH
params:params
httpMethod:@"POST"];
[op setFreezable:YES];
[op onCompletion:^(MKNetworkOperation *completedOperation) {
// ...
// Here is where I process response and send the result to my completion block
// It's called when WiFi is available, but not called otherwise.
// ...
} onError:^(NSError *error) {
// It's called when WiFi is available, but not called otherwise.
DLog(@"Some error");
}];
[self enqueueOperation:op];
return op;