使用 SearchBar、SearchDisplayController 和 UITableView 进行搜索的有效方法

Posted

技术标签:

【中文标题】使用 SearchBar、SearchDisplayController 和 UITableView 进行搜索的有效方法【英文标题】:Efficient approach to do search using SearchBar,SearchDisplayController and UITableView 【发布时间】:2009-07-21 04:55:05 【问题描述】:

我想使用 SearchBar、SearchDisplayController 和 UITableView 进行邮政编码搜索。我正在考虑使用 CoreData 来做这件事,但我仍然想知道是否有人有一些有效的想法来做同样的事情。

并且数据库有15000行,所以建议将sqlite文件移植到应用程序中并使用核心数据API来获取结果。

谢谢, 阿米特

【问题讨论】:

【参考方案1】:

CoreData 最常用的持久化存储是在 sqlite3 之上实现的,因此它们在原始提取性能等方面具有相当相似的性能特征。它有很多代码可以在后台处理对象中的故障而不会阻塞,在内存压力下驱逐它们并在必要时透明地拒绝它们等。从最严格的意义上讲,如果您要花费大量时间(想想数月到数年)优化特定情况,那么直接的 sqlite3 实现可以击败 CoreData,但是在绝大多数情况下,CoreData 将击败任何基于 sqlite3 的简单实现。

【讨论】:

以上是关于使用 SearchBar、SearchDisplayController 和 UITableView 进行搜索的有效方法的主要内容,如果未能解决你的问题,请参考以下文章

TableView 的 SearchBar 不起作用

UISearchController searchBar 不更新 barTintColor

如何使用代码将 UISearchController Searchbar 放到导航栏上

SearchBar 可点击结果 - 核心数据

SwiftUI 2个问题但很简单,关于searchBar和list的backgroundImage

如何以编程方式取消使用 searchBar 和 fetchedResultsController 的搜索?