Namaste!

I'm not sure how to proceed with the above.

First question:  where is the best place to implement populating a
brand-spanking-new SQLite store with some default data (I have some "hidden"
tables that need records)?  

I'd like to do this just after the store is actually created, so I am
looking at the application delegate's -persistentStoreCoordinator method.  I
know the store is created therein if it doesn't exist, however, whether it
is actually created or simply returning an existing store I can readily see
from the code written.  Examining the methods used to create the store
doesn't shed light on an answer either.  The routine itself states it
creates a store in the generated comments, but doesn't say whether it
returns an existing store...

There's an if statement onto which I could tack an else that I could use to
facilitate the population activity, but, because I am not sure the status of
the routine is creation-only, I'm hesitant to put it there.  

Second question:  how to actually add records?

I've looked at -insertNewObjectForEntityForName which is pretty
straightforward.  My question is actually when one has bunches of records
what is the correct methodology to implement this?  Is it something like:

NSManagedObject *someObject = [NSEntityDescription
insertNewObjectForEntityForName...];
[someObject setValue:value forKey:@"attribute"];
[someObject setValue:value forKey:@"attribute2"];
...
[...save];  // save this instance to the store

// lather, rinse, repeat for each record?

Also, I saw something about sending that -save message, but can't remember
where I found that - is that necessary as well?  If it is, it ought to be
part of the dox for the insertNewObject... since it is a necessary piece of
the pie.

Many thanks in advance for the helpful advice!!!

Peace, Love, and Light,

/s/ Jon C. Munson II


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to