gpt4 book ai didi

ios - 在 Cloudkit 中使用子查询

转载 作者:行者123 更新时间:2023-11-29 02:25:33 24 4
gpt4 key购买 nike

有人知道如何在 CloudKit 中使用子查询吗?这是我的尝试代码:

// stringArray is String list in Cloudkit
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SUBQUERY(stringArray, $fS, ANY $fS = %@).@count != 0", targetString];
CKQuery *query = [[CKQuery alloc] initWithRecordType:@"TestRecord" predicate:predicate];
[publicDatabase performQuery:query inZoneWithID:nil completionHandler:^(NSArray *results, NSError *error) {
NSLog(@"%@", results);
}];

但捕获到 CKException 并显示失败消息 Expected key-path in comparison expression: SUBQUERY(stringArray, $fS, ANY $fS = "targetString").@count != 0

有什么想法或有什么问题吗?

最佳答案

查看有关 NSPredicates for CloudKit 的文档。 https://developer.apple.com/library/ios/documentation/CloudKit/Reference/CKQuery_class/index.html#//apple_ref/swift/cl/CKQuery

如您所见,它只允许您为完整的 NSPredicate 类执行的操作的一个子集。子查询和聚合(如 .@count)是不允许的。

关于ios - 在 Cloudkit 中使用子查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27587339/

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