设备脱机时CKQueryOperation不返回错误

我正在尝试使用CKQueryOperation ,而performQuery在我的CloudKit数据库执行查询。

这两个工作,但是当使用CKQueryOperation我没有得到一个错误,当设备脱机,但我使用performQuery

这里是我的performQuery例子的裸骨头,数据库是我的CKDatabase

 database.performQuery(q, inZoneWithID: nil) { (records:[CKRecord]?, error:NSError?) in if error != nil { print(error!.localizedDescription) return } } 

设备处于脱机状态时发生错误,允许我提示用户。 错误是

The internet connection appears to be offline

但是,当我使用CKQueryOperation时,我没有得到任何错误

 let p = NSPredicate(format:"recordID IN %@", student.courses) let q = CKQuery(recordType: String(Course), predicate: p) let queryOperation = CKQueryOperation(query: q) queryOperation.recordFetchedBlock = { record in // not called without network connection - doesn't enter scope print(record) } queryOperation.queryCompletionBlock = { (cursor: CKQueryCursor?, error: NSError?) in // not called without network connection - doesn't enter scope print(cursor) print(error) } database.addOperation(queryOperation) 

通过连接,我接收两种方法的数据,以便按预期工作。

我在使用CKQueryOperation时如何/在哪里通知错误?

谢谢

按照惯例,我会发一个赏金,并在接下来的一小时内find答案。2.不知道我是如何错过这个最初的,但它包含了我正在寻找的答案。

所以join这一行

 queryOperation.qualityOfService = .UserInitiated 

幕后的事情发生了变化,我们在内部有一些很好的行动

 queryOperation.queryCompletionBlock = { (cursor: CKQueryCursor?, error: NSError?) in // We get an error message... Finally !! print(error) } 

在Apple Docs中找不到任何东西来暗示这一点。