Tutorial :Store large lists of data in iPhone app so they are available to the UI



Question:

A bit cryptic, which is also what drives me to start a thread in here, I simply can't find 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:

  1. Write a script to have it preloaded into my Core Data Model and pull it from there when I need the list.

  2. Build a plist file I bundle with the app and read the data out from there.

  3. Put a text/xml/json file into the app and read it from there..

  4. 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


Solution:1

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];  


Solution:2

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.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »