tags:

views:

435

answers:

2

Hi

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.

Im 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 Im done with it. (I pull a string value from the selection and stuff it into my webservice querry) 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

+1  A: 

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.

Corey Porter
Thanks, seems you both lean towards the plist approach, just to be sure when you mention startup time, you mean when I ask for the list? Plists don't get loaded into memory upon app startup? Thanks again, I'll give it a spin and see the impact on load time compared to now where I get the data from a webservice as xml and parse it (around 18 sec. on 3G).
RickiG
The problem with plists is they need to be completely read into memory before you can use them, so for very large data sets it can be an issue, both the load time (you only get ~10-15MB/s read speed from flash on the iPhone), and the amount of memory they can take up once loaded. For your dataset that is probably not an issue, but if you had a large data set you want something that allowed incremental loading (CoreData or SQLite).
Louis Gerbarg
Hi LouisNo I think Im in the area of 1.2 MB for the 16,000 entries document.So now I parsed them, stuffed them into a dictionary, just need to find out how I save them to my disk(my Mac disk) as all this is done in the iPhone simulator:)The rest of my app uses Core Data, but that is mostly because it is relational.. don't like using Core Data for "just large lists" .. Im picky:)
RickiG
WOW! did I just spend 3 hours of having my patience tested..Turns out if I save my values in a NSDictionary (which is perfect cause my values are an ID and a value), they are pretty much useless when I retrieve them an think I can put them in a tableView: hint, there is no ObjectAtIndex method on a NSDictionary so cellForRowAtIndexPath get's kinda hard. Ok I guess I could write them as value objects saved in an array an write the array to a plist.. can't use custom objects in arrays if you what to persist them in a plist without NSEncoding..Please someone tell me this is a misunderstanding?
RickiG
Ok to sum up on the solution and the great advise from you guys:I build two plist files out of two NSDictionaries. 90KB and 800KB I load these up, stuff the Dictionary key and object into a ValueObject (NSObject with two NSString properties) them use that as a datasource for my tableView. In both cases the time it takes from the user asks for the data to it is presented is so small both on the simulator and on my phone that it is irrelevant.So now I know that at least for lists up to 16,000 entries it is no problem using plist -> NSDictionary -> valueObject("Entry" I guess in core data).thx
RickiG
+1  A: 

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];
Ken Pespisa
Thank you too Ken.I'll try it out straight away:)
RickiG
I agree it is easiest, and this case probably a reasonable solution, but it is nowhere near fastest. XML parsing is actually very expensive, and plists are atomic, which means you need to pull in the whole thing, which is pretty expensive on an iPhone. A binary plist will slaughter an XML plist in terms of speed, and depending on the exact size of the file CoreData will be faster than a binary plist since it doesn't need to read the whole thing at once.
Louis Gerbarg