简体   繁体   English

CloudKit:CKQuery显示错误:错误:操作无法完成。 (CKErrorDomain错误1。)

[英]CloudKit : CKQuery showing error: error: The operation couldn’t be completed. (CKErrorDomain error 1.)

I working on iOS app implementing cloudkit but I need to query all the records with ID greater then a number. 我正在开发实现cloudkit的iOS应用,但是我需要查询ID大于数字的所有记录。 For example I have record with ID of 23: 例如,我有ID为23的记录:

在此处输入图片说明

here is my code: 这是我的代码:

CKContainer *myContainer = [CKContainer containerWithIdentifier:containerID];

    CKDatabase *publicDatabase = [myContainer publicCloudDatabase];


CKRecordID *recordID = [[CKRecordID alloc] initWithRecordName:@"23"];
    CKReference* recordToMatch = [[CKReference alloc] initWithRecordID:recordID action:CKReferenceActionNone];
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"recordID >= %@", recordToMatch];
    CKQuery *query = [[CKQuery alloc] initWithRecordType:recordType predicate:predicate];

    [publicDatabase performQuery:query inZoneWithID:nil completionHandler:^(NSArray *results, NSError *error) {
        if (error) {

            NSLog(@"error: %@", error.localizedDescription);
        }
        else {

        }
    }];

But I'm getting the following error: 但我收到以下错误:

error: error: The operation couldn't be completed. 错误:错误:操作无法完成。 (CKErrorDomain error 1.) (CKErrorDomain错误1。)

Any of you knows how can I setup my NSPredicate in a way where I can get all the records with ID greater then 23 ? 你们谁都知道如何设置NSPredicate的方式来获取ID大于23的所有记录?

I'll really appreciate your help. 非常感谢您的帮助。

For a query like this you could use a predicate like: 对于这样的查询,您可以使用如下谓词:

in Swift: 在Swift中:

var predicate = NSPredicate(format: "recordID >= %@", CKRecordID(recordName: "23"))

In Objective C: 在目标C中:

 NSPredicate *predicate = [NSPredicate predicateWithFormat:@"recordID >= %@", [CKRecordID initWithRecordName:@"23"]];

Then I do assume that you created the CKRecords object originally while specifying this number. 然后,我确实假定您在指定此数字时最初创建了CKRecords对象。 Otherwise recordID values will be assigned by CloudKit and will be a GUID. 否则,recordID值将由CloudKit分配,并将为GUID。

Your recordID of 23 is stored as a CKRecordID type and not as a number thus you cannot use any numeric predicates like greater-than. 您的recordID为23是作为CKRecordID类型而不是数字存储的,因此您不能使用任何数字谓词,例如大于。 You should create a new number field in your record for storing your integer IDs and query that instead. 您应该在记录中创建一个新的数字字段,以存储您的整数ID并对其进行查询。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法完成操作。 (AppThinning.StubError 错误 1。) - The operation couldn’t be completed. (AppThinning.StubError error 1.) 该操作无法完成。 (可可错误-1。) - PHPhotoLibrary - The operation couldn’t be completed. (Cocoa error -1.) - PHPhotoLibrary 将视频保存到我的相机胶卷中会返回错误:无法完成该操作。 (可可错误-1。) - Saving a video to my camera roll returns error: The operation couldn’t be completed. (Cocoa error -1.) 解压缩错误操作无法完成。 (ViewControllers之间的(Zip.ZipError错误1.) - Unzipping Error The operation couldn’t be completed. (Zip.ZipError error 1.) between ViewControllers 该操作无法完成。 (Starscream.WSError错误1。)RBSManager - The operation couldn't be completed. (Starscream.WSError error 1.) RBSManager 错误:exportArchive:无法完成操作。 (IDEDistributionErrorDomain错误3.) - error: exportArchive: The operation couldn’t be completed. (IDEDistributionErrorDomain error 3.) 错误:该操作无法完成。 (LaunchServicesError错误0。) - Error: The operation couldn’t be completed. (LaunchServicesError error 0.) 错误:无法将输入文件读取为属性列表:操作无法完成。 (XCBUtil.PropertyListConversionError 错误 1。) - error: unable to read input file as a property list: The operation couldn’t be completed. (XCBUtil.PropertyListConversionError error 1.) MidiClientCreate“操作无法完成。 (OSStatus错误-50。)” - MidiClientCreate “The operation couldn't be completed. (OSStatus error -50.)” 该操作无法完成。 (OSStatus错误-10827。) - The operation couldn’t be completed. (OSStatus error -10827.)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM