Re: core data newbie Q
Re: core data newbie Q
- Subject: Re: core data newbie Q
- From: Daniel Child <email@hidden>
- Date: Tue, 05 Jun 2007 14:08:52 -0400
Thanks for clearing that up. I was confusing the internal storage
format with data to import.
This seems to suggest that I have to create two classes: 1) a class
representing the data to be imported (probably storing in an array of
that class), and 2) an NSManagedObject which mirrors the class and
converts each object's instance variables into entity attributes. Is
that the standard approach, or am I still muddling things up?
Thanks.
On Jun 5, 2007, at 9:38 AM, Andrew Kimpton wrote:
On Jun 5, 2007, at 9:24 AM, Daniel Child wrote:
Hi,
I have been reading up on the Core Data documentation. One thing I
don't see answered in the documentation is how you can import data
that is not in XML, SQLite, or binary format.
In other words, what steps would you take to import a comma- or
tab-delimited flat file.
Don't confuse the internal storage formats that CoreData uses with
what can be imported. The two are not connected, primarily because
importing data is entirely your responsibility. Your app needs to
parse the input file using NSScanner (or whatever other tools you
wish to use), create an NSManagedObject (or child class) instance,
using insertNewObjectForEntityName and then set the appropriate
values on it from the results of your parsing.
The Core Data Programming Guide has a section 'Efficiently
importing legacy data' which goes over some of the 'gotchas' that
you might run into (see also other recent posts about autorelease
pools and CoreData memory usage if you're importing thousands of
objects).
Andrew 8-)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden