I need to download and parse some XML data, and to store it in sqlite. Then I need to present that data on table view. I’m trying to figure out the most effective way how to present that data further: take form sqlite and use it for table view that also uses a search. Therefore, I need to copy that data from the sqlite “source” into some “table data” property/ies in my table view controller. So, the two common ways are:
-
To have one NSArray property that contains section names (for example NSString type) and to have NSDictionary property (for storing rows) that keys are the section names contained in the first NSArray.
-
To have only one nested NSArray property (matrix): NSArray would contain elements that are also NSArrays, and each element in inner NSArray is a type of CustomClass of NSDictionary.
-
Other ways, please ….
I’m wondering what road should I take and what are pros and cons of those two (and maybe other) ways. Please share your experience and insights.
Why don’t you use Core Data to store your data? It uses sqlite as the back-end if the store type of the NSPeristentStoreCoordinator is NSSQLiteStoreType. If you are not familiar with it, make a new project, tick Use Core Data on creation. You will need to spend some time to learn it, but it is worth it. It’s all there, storing, searching, filtering, sorting, displaying in a table view, etc.