在私有数据库的ckzone中查询共享记录不会返回任何内容 [英] Querying shared records in a ckzone in the private database returns nothing

查看:122
本文介绍了在私有数据库的ckzone中查询共享记录不会返回任何内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Swift 4.2 iOS 11.x

Swift 4.2 iOS 11.x

我肯定错过了一些东西,因为这肯定可以工作。我得到了在自定义区域中查询私有数据库的代码。尽管我在那里有记录,但它什么也没返回。我为所有内容添加了索引!我还更改了权限中的角色,以便任何经过身份验证的用户都可以读取记录。

I must have missed something cause this surely should work. I got this code that queries the private database in a custom zone. It returns nothing despite the fact that I have records there. I added indexes to everything! I also changed the roles in permissions so that any authenticated user could read records.

public func cleanUpImages(zone2U:String) {
    var records2Delete:[CKRecord.ID] = []
    let zone2D = CKRecordZone(zoneName: zone2U)

    let predicate = NSPredicate(value: true)
    let query = CKQuery(recordType: remoteRecords.notificationMedia, predicate: predicate)
    let operation = CKQueryOperation(query: query)
    operation.recordFetchedBlock = { record in
        records2Delete.append(record.recordID)
    }
    operation.queryCompletionBlock = { cursor, error in
        print(records2Delete.count)
    }
    CKContainer.default().privateCloudDatabase.add(operation)

notificationMedia是一个全局静态变量,我也使用它来保存所述记录,因此它不会出错/不同。

notificationMedia is a global static var that I also use to save said records, so it cannot be wrong/different.

推荐答案

设置操作的 zoneID ,因为现在您正在查询默认区域。

Set the zoneID of operation because right now you are querying the default zone.

let operation = CKQueryOperation(query: query)
operation.zoneID = zone2D.zoneID

这篇关于在私有数据库的ckzone中查询共享记录不会返回任何内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆