Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有人有一个很好的为 UISearchBar 存储书签的示例?最优雅的存储方式是什么?任何示例代码将不胜感激。
使用 NSMutableArray。每当用户搜索某些东西时,将字符串对象添加到数组中。如果要显示书签列表,请在搜索栏下方有一个表格视图,其中包含与关键字匹配的书签列表。如果任何书签与关键字匹配,则使 tableview 可见,否则隐藏。如果您想在本地保存书签以在应用程序启动时保持不变,您可以使用 [array writeToFile:@"filename"]; 您可以通过 [NSMutableArray arrayWithContentsOfFile:"filename"]; 检索