• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Populating a new SQLite Core Data store with default data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Populating a new SQLite Core Data store with default data


  • Subject: Populating a new SQLite Core Data store with default data
  • From: "Jon C. Munson II" <email@hidden>
  • Date: Fri, 20 Feb 2009 12:38:50 -0500
  • Organization: JTA Enterprises LLC

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 (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Populating a new SQLite Core Data store with default data
      • From: mmalc Crawford <email@hidden>
  • Prev by Date: Re: Question on pasteboard manager
  • Next by Date: Re: (no subject)
  • Previous by thread: Re: Question on pasteboard manager
  • Next by thread: Re: Populating a new SQLite Core Data store with default data
  • Index(es):
    • Date
    • Thread