gpt4 book ai didi

ios - NSPredicate 和 BEGINSWITH 与 CloudKit : Field value type mismatch

转载 作者:行者123 更新时间:2023-12-01 18:56:11 25 4
gpt4 key购买 nike

我有一个带有字符串类型属性“名称”的表“存储”(检查排序查询和搜索的索引)。
我想执行类似 SQL 的查询来查找名称以子字符串开头的所有商店。

所以我尝试了这个谓词:

NSPredicate *pred = [NSPredicate predicateWithFormat:@"ANY name BEGINSWITH %@",substring];

CKQuery *query = [[CKQuery alloc]initWithRecordType:@"Store" predicate:pred];

CKQueryOperation *queryOperation = [[CKQueryOperation alloc] initWithQuery:query];

queryOperation.desiredKeys = @[@"name",@"category"];

NSMutableArray *results = [[NSMutableArray alloc] init];

queryOperation.recordFetchedBlock = ^(CKRecord *record) {
[results addObject:record];
};
queryOperation.queryCompletionBlock = ^(CKQueryCursor *cursor, NSError *error) {
//my own code
}
[publicDatabase addOperation:queryOperation];

我有这个错误:
<CKError 0x1887a540: "Invalid Arguments" (12/1009); "Field value type mismatch in query predicate for field 'name'"> for query : <CKQuery: 0x18882650; recordType=Store, predicate=ANY name BEGINSWITH "mysubstring">

最佳答案

我的猜测是你需要摆脱“ANY”。

The ANY and SOME aggregate operators may be combined with the IN and CONTAINS operators to perform list membership tests.



所以 ANY 用于列表(数组)。由于'name'是一个字符串,它不是一个列表,因此不匹配错误:“字段'name'的查询谓词中的字段值类型不匹配”

关于ios - NSPredicate 和 BEGINSWITH 与 CloudKit : Field value type mismatch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26792249/

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