1
当我试图从核心数据获取超过1000个NSManagedObjects,我的应用程序崩溃与此消息:获取超过1000时,核心数据碰撞对象
error: (1) I/O error for database at .../Documents/Stores/Model.sqlite.
SQLite error code:1, 'Expression tree is too large (maximum depth 1000)'
CoreData: error: (1) I/O error for database at .../Documents/Stores/Model.sqlite.
SQLite error code:1, 'Expression tree is too large (maximum depth 1000)'
我用它来获取由用户选择的对象的代码是这样的:
NSManagedObjectContext *context = cdh.context;
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Spot" inManagedObjectContext:context];
NSError *error = nil;
[request setEntity:entity];
request.includesPropertyValues = NO;
NSMutableArray *subPredicatesArray = [NSMutableArray array];
for (NSString *string in uuidStrings)
{
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K like %@", @"sID", string];
[subPredicatesArray addObject:predicate];
}
NSCompoundPredicate *compoundPredicate = [NSCompoundPredicate orPredicateWithSubpredicates:subPredicatesArray];
[request setPredicate:compoundPredicate];
NSArray *fetchedObjects = [context executeFetchRequest:request error:&error];
有没有更好的方式来获取1000+对象,这将不会导致我的应用程序崩溃?
我不知道该限制没有。 :) –
直到我反对它,我也没有! – EmilyP