Search code examples
iphoneuitableviewiphone-sdk-3.0plist

iPhone long plist


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


Solution

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