views:

302

answers:

1

I am building an iPhone application which pulls a lot of information from an webservices that sends XML.

The problem now is that I am going to import a set of data that needs to import in 4 or 5 related tables. It depends if the city exists in Core data.

The database looks like this: City - Club - track

The way how I would do it now is to put all the data in the database for each model. So I would loop 4 or 5 times the data an put this in the database. But in my head I think there has to be a better way.

A: 

One basic document is this Apple CoreData doc called "Efficiently importing data". I am also building an app like yours (although on a Mac), and had implemented a very stupid importing routine which was very slow. Following the recommendation in that document made a huge difference and made importing much, much faster! Pay your attention in particular to the last section, "Implementing Find-or-Create Efficiently".

Yuji
Today I read the whole stuff. I know changed the database so I always import new data to 4 related tables.What I did understand is that you still need to loop 4 times all the data and import that. In my case it is probably 20-40 records so it isn't that much.
Marko