Search as you type for large Core-Data data set
I have a large core-data data set and i want to add search support. Currently i'm using fetched results controller to show the data in a uitableview. I'm planning on using UISearchDisplayController. Now i have two options:
- Create a new fetched results controller for searched data
- Use an array to show the filtered data
Which approach is more appropriate/recommended (particularly for search-as-you-type)? Is there any book or tutorial that addresses how to implement the suggested solution开发者_JAVA百科?
In several projects I went with the "new fetched results controller" option because the data that I was filtering possibly could eat up all of the ram in the older iPhones. The FRC can handle low memory issues. This stackoverflow answer might be helpful to you if you go ith this option
Is your data small enough to fit within the usable ram of the lowest common denominator (1st generation iPhone)? If so then just filter in memory using a NSArray. Performance wise, this would be faster than using the FRC.
Is the data constantly being written to? I had a set of 1,200 records to search through via a 'contains' search. What I did was on app launch have an object that contains all the data sets based on the coredata store. If the data gets updated during app use - it re-builds the sets.
Then when I get to the searching table view I search through the pre-loaded data. Doing a fetch each time caused too much lag - even with well written predicates and fetched results controller. I found it far faster to do it manually as I could create subsets of the data for faster searching.
Hope this helps makes your decision.
Cheers,
Michael
精彩评论