gpt4 book ai didi

ios - 如何从cloudkit下载多条记录

转载 作者:搜寻专家 更新时间:2023-11-01 07:21:32 26 4
gpt4 key购买 nike

我正在尝试从云工具包下载多个项目,但出现错误“无法分配类型值 (CKQueryCursor!, NSError) -> () to type (CKQueryCursor?, NSError?) -> void”

let locationToLookFor = CLLocation() 
let predicate = NSPredicate(format: "location = %@", locationToLookFor as CLLocation)
let query = CKQuery(recordType: "Location", predicate: predicate)
let operation = CKQueryOperation(query: query)
operation.recordFetchedBlock = self.recordFetchBlock
operation.queryCompletionBlock =
{
[weak self]
(cursor: CKQueryCursor!, error: NSError) in
if(cursor != nil)
{
print("Fetching records")
let newOperation = CKQueryOperation(cursor: cursor)
operation.recordFetchedBlock = recordFetchBlock
operation.queryCompletionBlock = operation.queryCompletionBlock
self!.operationQueue.addOperation(newOperation)
}
else {
print("We have fetched all data")
}
}
operationQueue.addOperation(operation)

最佳答案

您的关闭签名与要求的签名不匹配。如错误消息所示,cursorerror 一样应该是可选的。您还会收到一个错误,因为您在将 cursor 提供给新操作时没有解包。

尝试:

operation.queryCompletionBlock =
{
[weak self]
(cursor: CKQueryCursor?, error: NSError?) -> Void in
if let cursor = cursor
{
print("Fetching records")
let newOperation = CKQueryOperation(cursor: cursor)
operation.recordFetchedBlock = recordFetchBlock
operation.queryCompletionBlock = operation.queryCompletionBlock
self?.operationQueue.addOperation(newOperation)
}
else {
print("We have fetched all data")
}
}

关于ios - 如何从cloudkit下载多条记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38687783/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com