• 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
Re: Core Data - Initializing with standard data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data - Initializing with standard data


  • Subject: Re: Core Data - Initializing with standard data
  • From: mmalcolm crawford <email@hidden>
  • Date: Sat, 22 Oct 2005 10:02:12 -0700


On Oct 22, 2005, at 9:29 AM, Gian Marc Cadosch wrote:

I created the initial project with XCode 2.2 with the "Core Data Application"
setting. Now I'm asking me where to place the import call (importing is already
implemented but has to be started through the menu yet). How can I determine if
the store was just created (and so it needs to import the data) or just opened?

Remember that just because you're using Core Data doesn't mean you don't(*) have access to all the standard Cocoa tools and techniques...


(* Note the double negative.)


if ( ![fileManager fileExistsAtPath:applicationSupportFolder isDirectory:NULL] ) {
[fileManager createDirectoryAtPath:applicationSupportFolder attributes:nil];
}


url = [NSURL fileURLWithPath: [applicationSupportFolder stringByAppendingPathComponent: @"Delete.xml"]];


Add a check to determine whether the file at the url exists. If it doesn't, you need to import the data...



If there's some reason that there might be a possibility that the store (hence file) gets created but the data is not imported, then you might consider adding a metedata flag to the store, since you can check that more efficiently than executing a fetch (and it doesn't require you to hard code any default data values).


mmalc

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Core Data - Initializing with standard data (From: Gian Marc Cadosch <email@hidden>)

  • Prev by Date: Re: How to change a Push Button's Color?
  • Next by Date: Name of current function/selector
  • Previous by thread: Re: Core Data - Initializing with standard data
  • Next by thread: Re: Core Data - Initializing with standard data
  • Index(es):
    • Date
    • Thread