views:

318

answers:

3

I am new to iphone development.I want insert my xml parsed contents into a sqlite3 database and retrieve it and display it in a tableView.I am able to parse and directly display the contents using nsxml parser.Please help me how to proceed to store the contents in a database and retrieve it .Thanks.

+1  A: 

You should consider using Core Data instead of sqlite3. It manages automatically for you most of the hard works, and it loads to TableView efficiently.

sfa
+1  A: 

You can do your parsing offline (i.e. not in the iPhone app) or online (i.e. in the iPhone app). It depends on if you need your XML available to the app at runtime.

If you're just interested in the contents of the XML file being inside the SQLite DB, then I'd recommend doing the parsing offline, because your app will run faster since it isn't parsing XML each time it's launched.

As Hoang said, you should consider using Core Data if possible, which can use SQLite for its backing store. This depends on if your app needs to run on pre-OS 3.x devices, as Core Data is only available in iPhone OS 3.0b and later. Core Data makes handling databases so much easier, and provides a few neat little things to make building an app simpler (like NSFetchedResultsController).

I asked a similar question a few months ago. Based on the responses I got, I wrote a Cocoa-based command line utility, which I run to pre-process my data into an SQLite DB form, which my iPhone app project just includes as another resource. Since you're already using NSXMLParser, my guess is most of your parsing code should easily "port" over with a copy-and-paste.

Shaggy Frog
+1  A: 

Make sure you read Core Data Programming Guide, before you use it.

It's not something that could be easily understood by beginners.

Your project and Apple's sample codes may have different situation. Also pay attention on performance, especially on the device.

Jesse Armand