PDA

View Full Version : Core data importing entities




MacDonaldsd
Jul 29, 2007, 04:51 AM
Im building an application that relies heavily on core data.

I was wondering if there is a way to import a single instance of a entity ?

Maybe by running a applescript or something ?



Eraserhead
Jul 29, 2007, 01:07 PM
Do you mean that you want import an NSManagedObject from one model to another?

Do you wish to copy related objects as well?

MacDonaldsd
Jul 30, 2007, 06:42 AM
Basically Im doing a timetable application. So modules that are related to assessments is what im referring to here.

I would like to be able to just import assessment details. So a user can just import the details rather than typing them manually as everyone will have the same information.

Eraserhead
Jul 30, 2007, 08:56 AM
So you want to import the assessment information from another file into your Core Data model for your application?

In which case you'll need to read in the data using a normal (non Core Data) Cocoa data input system and then attach the data to the relevant NSManagedObject.

MacDonaldsd
Jul 30, 2007, 11:56 AM
So you want to import the assessment information from another file into your Core Data model for your application?

In which case you'll need to read in the data using a normal (non Core Data) Cocoa data input system and then attach the data to the relevant NSManagedObject.

So read it to a Normal object, then copy/create a NSManagedObject using code "behind the scenes" ?

Eraserhead
Jul 30, 2007, 12:17 PM
Pretty much but you may not need to read it into a normal object at all as you may be able to read it as an int, double, BOOL, NSString etc. and then attach it directly to the NSManagedObject you wish to store the data in.

However you have the basic idea.