My application needs to run a CKQueryOperation using a CKDatabase. This requires network access which is not always available.
Once I add a CKQueryOperation to the CKDatabase that’s about where my control stops.
Is there a way I can:
I know I can do this with CKDatabase performQuery however I would prefer to use operations if possible, thanks in advance for your help!
For timeout you can set configuration object on the CKQueryOperation:
let config = CKOperation.Configuration()
config.timeoutIntervalForRequest = 5
config.timeoutIntervalForResource = 5
// Config operation
let operation = CKQueryOperation(query: query)
operation.configuration = config
operation.other_stuff..
operation.queryCompletionBlock = { (_, error: Error?) in
guard error == nil else {
// Handle timeout error here.
return
}
...
}
Default timeout is 60 seconds.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With