gpt4 book ai didi

objective-c - 如何使用大型核心数据集实现更快的搜索

转载 作者:行者123 更新时间:2023-11-29 13:37:07 24 4
gpt4 key购买 nike

我正在开发应用程序,我想在其中显示 10k+ 的 tableview 我正在使用来自 cs193p 的 fetchedresultcontroller,它运行良好。加载和滚动非常快。我希望能够搜索每个字母。
我设置了搜索栏和委托(delegate),并让搜索栏 textdidchange 方法为每个字母重新加载 fetchresults Controller 。它可以工作,但无论如何都会有延迟以使其更快。这是我的 textdidchange 方法

-(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {

//NSLog(@"%@",searchText);
NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"People"];
request.sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"fullname" ascending:YES]];
[NSFetchedResultsController deleteCacheWithName:@"peopleCache"];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(firstname contains[c] %@)",searchText];
request.predicate = predicate;

self.fetchedResultsController = [[NSFetchedResultsController alloc]initWithFetchRequest:request managedObjectContext:self.peopleDatabase.managedObjectContext sectionNameKeyPath:nil cacheName:@"actorCache"];

有没有什么方法可以在不实际重新获取数据的情况下过滤现有查询?

任何建议将不胜感激!

最佳答案

Optimizing Core Data Performance on iPhone OS” WWDC session 中提到了优化文本搜索的技巧。

关于objective-c - 如何使用大型核心数据集实现更快的搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10290834/

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