Keyboard NSPredicate搜索键盘滞后

Keyboard NSPredicate搜索键盘滞后,keyboard,nspredicate,lag,Keyboard,Nspredicate,Lag,我在NSPredicate搜索中遇到一些键盘延迟: 一些代码: - (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope { NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"(head beginswith[c] %@) OR (pro beginswith[c] %@) OR (searchable

我在NSPredicate搜索中遇到一些键盘延迟:

一些代码:

- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{

    NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"(head beginswith[c] %@) OR (pro beginswith[c] %@) OR (searchableStringValue beginswith[c] %@)", searchText, searchText, searchText];

    searchResults = [chengduhua filteredArrayUsingPredicate:resultPredicate];
}
&&&&


编辑:我在“取消”(输入文本时搜索栏最右侧的“x”)上也遇到严重延迟。

发生这种情况是因为您在SearchDisplay delegate中执行的操作需要时间

您应该检查
搜索结果的大小

searchResults = [chengduhua filteredArrayUsingPredicate:resultPredicate];

尝试限制结果

我在上面添加了一个编辑:编辑:我在“取消”(输入文本时搜索栏最右边的“x”)上也遇到了严重的延迟。你应该显示更多的代码。试着用仪器找出什么需要时间。你应该学会使用
searchResults = [chengduhua filteredArrayUsingPredicate:resultPredicate];