gpt4 book ai didi

ios - 核心数据 : Expression tree is too large

转载 作者:行者123 更新时间:2023-11-29 12:36:46 24 4
gpt4 key购买 nike

我需要一些关于此方法的帮助:

// deletes all points in database except points with given identifiers
- (void)deleteAllPointsExcept:(NSArray *)safeIdentifiers save:(BOOL)save {
// create request to fetch all 'doomed' points
NSManagedObjectContext *context = [[TSAppDelegate delegate] managedObjectContext];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:@"MapPoint"];
NSMutableArray *subpredicates = [NSMutableArray array];

for (NSNumber *identifier in safeIdentifiers) {
NSPredicate *pred = [NSPredicate predicateWithFormat:@"pid!=%@", identifier];
[subpredicates addObject:pred];
}
fetchRequest.predicate = [NSCompoundPredicate andPredicateWithSubpredicates:subpredicates];

// fetch 'em & destroy 'em
NSError *error;
NSArray *points = [context executeFetchRequest:fetchRequest error:&error];

for (TSMapPoint *point in points) {
[context deleteObject:point];
}

// save if requested
if (save) {
[[[TSAppDelegate delegate] managedObjectContext] save:NULL];
}
}

它应该从我的核心数据 NSManagedObjectContext 中清除不需要的 MapPoints。它工作正常,但有一天我收到了这条消息:

CoreData: error: (1) I/O error for database at ...  SQLite error code:1, 'Expression tree is too large (maximum depth 1000)'

我在谷歌上搜索过,当谓词太长时会发生这种情况,例如 WHERE id=1 OR id=2 OR id=3 ... 但我不知道如何解决这个问题.有人有想法吗?

提前致谢,皮特。

最佳答案

您的谓词应简化为如下所示

[NSPredicate predicateWithFormat:@"NOT (pid IN %@)", safeIdentifiers];

关于ios - 核心数据 : Expression tree is too large,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26105471/

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