[英]CKQueryOperation visibility, cancellation and timeout possibilities
My application needs to run a CKQueryOperation using a CKDatabase. 我的应用程序需要使用CKDatabase运行CKQueryOperation。 This requires network access which is not always available. 这需要网络访问并不总是可用。
Once I add a CKQueryOperation to the CKDatabase that's about where my control stops. 一旦我将CKQueryOperation添加到CKDatabase,这是关于我的控件停止的位置。
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! 我知道我可以用CKDatabase performQuery做到这一点但是我希望尽可能使用操作,提前感谢您的帮助!
For timeout you can set configuration object on the CKQueryOperation: 对于超时,您可以在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. 默认超时为60秒。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.