views:

171

answers:

3

I have some data i want to add in to my app...about 650 categories (includes a name + id number), each with an average of 85 items (each with a name/id number).

Will the iPhone support such a large plist? I want to first display the categories in a UITableView, when a category is selected I want to display all of the associated items. Having such a large plist, im not sure if the iPhone will lag when loading the items. At over 51,000 lines it seems like...it might.

EDIT: The raw text file is 2MB

+1  A: 

I suspect it would probably take a while to load your plist, especially if you are using an XML based plist. A binary plist may be faster. You may want to consider using CoreData or a raw sqlite database to store your data instead.

The only way to be sure is to try it and see. Nothing beats actual performance timings.

Daniel
A: 

That really seems better suited to pre-loading a database with. It should be somewhat smaller for one thing...

The technique is, write code to read the plist and put it in SQLlite or CoreData. Then take the database out of the simulator directory, and add it to your app - on app launch read the database from the file you have in the project.

If you need to modify the data, preload it but first copy the database into the writable directory on first launch (or basically anytime it is not there).

Kendall Helmstetter Gelner
+1  A: 

A plist can be of arbitrary length. But a plist with 2 MB of text data is a really bad idea. Even on the desktop, Apple only recommends plists with a maximum size of a couple hundred KB:

http://developer.apple.com/mac/library/documentation/cocoa/conceptual/propertylists/AboutPropertyLists/AboutPropertyLists.html#//apple_ref/doc/uid/10000048i-CH3-54402

The reason is plists must be deserialized entirely into memory before you can access a single element from the plist. This is convenient for small plists, but extraordinarily inefficient in space and time for large plists.

You should be loading your data into a database. If you do it properly, a database will only bring in the portion of the data set you need, rather than the entire data set.

orange