Prepopulated stored data in iOS4

浪尽此生 提交于 2020-01-06 08:32:08

问题


I work with iPhone iOS 4.3.

In my project I need a read-only, repopulated table of data (say a table with 20 rows and 20 fields).

This data has to be fetched by key on the row.

What is better approach? CoreData Archives, SQLite, or other? And how can I prepare and store this table?

Thank you.


回答1:


I would use core data for that. Drawback: You have to write a program (Desktop or iOS) to populate the persistent store.

How to use a pre-populated store, you should have a look into the Recipes sample code at apple's.




回答2:


The simplest approach would be to use an NSArray of NSDictionary objects and then save the array to disk as a plist. Include the plist in your build and then open it read only from the app bundle at runtime.

Each "row" would be the element index of the array which would return a dictionary object wherein each "column" would be a key-value pair.




回答3:


I've done this 2 different ways:

  1. Saved all my data as dictionaries in a plist, then deserialized everything and loaded it into the app during startup
  2. Created a program during development that populates the Core Data db. Save that db to the app bundle, then copy the db during app startup into the Documents folder for use as the Persistent Store

Both options are relatively easy, and if your initial data requirements get very large, it's also proven to be the most performant for me.



来源:https://stackoverflow.com/questions/6783283/prepopulated-stored-data-in-ios4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!