Store large lists of data in iPhone app so they are available to the UI
A bit cryptic, which is also what drives me to start a thread in here, I simply can't fi开发者_JAVA百科nd the words to Google the challenge.
I'm building an app that will have 2 search views that displays 1400 and 16000 possible choices. It is plain lists, no relational or otherwise spanning data.
As far as I can figure out I have 3 possibilities:
Write a script to have it preloaded into my Core Data Model and pull it from there when I need the list.
Build a plist file I bundle with the app and read the data out from there.
Put a text/xml/json file into the app and read it from there..
oh fourth crazy possibility, actually write a ValueObject.m that contains all these pieces of data.
I only need to display them in a tableView with a searchBar, have the user select one and I'm done with it. (I pull a string value from the selection and stuff it into my web service query)
As this is quite some lists, what would be a good way to go about it, I would like to avoid as much parsing/data handling as possible to speed things up.
Hope some can point me in a direction so I don't have to speed test each of these possibilities :) or even better someone comes along with a 5. and even better possibility:)
Thanks
Easiest way is to go with #2. You can't get much easier than an XML file that can be easily read into an NSArray. I don't have hard numbers, but I would have to guess this is the fastest option as well.
NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"largelist" ofType:@"plist"];
theArray = [NSArray arrayWithContentsOfFile:plistPath];
I've used the plist approach (although with far less data) and it works well. Give it a try. If startup time is acceptable, it's a very straightforward way to go. If it takes too long, CoreData seems best.
精彩评论