I'm creating a custom keyboard for iOS8, and I'm having a tough time figuring out some issues with NSURLConnection.
I'm using the sendAsynchronousRequest: method like this:
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
NSLog(@"recieved asynchronous response");
if (!connectionError) {
[self connection:nil didReceiveData:data];
[self connectionDidFinishLoading:nil];
}
else{
NSLog(@"connection failed - %@", connectionError);
}
}];
This all seems to work correctly for a period of time (1-2 days), and I can correctly receive data. After this time I start seeing the following error message:
***cachedResponseForRequest:key:handler failed:
Error Domain=NSCocoaErrorDomain Code=4099 "The operation couldn’t be completed. (Cocoa error 4099.)" (The connection to service named com.apple.nsurlstorage-cache was invalidated.) UserInfo=0x17579030 {NSDebugDescription=The connection to service named com.apple.nsurlstorage-cache was invalidated.}; { NSDebugDescription = "The connection to service named com.apple.nsurlstorage-cache was invalidated.";
The only way I then seem to be able to make things work correctly again is to reset the content and setting on the phone. If anyone could point me in the correct direction as to why this is happening I would be very grateful. Thanks in advance.