title: Pre Populate Core Data By Copying .sqlite File From Documents
body: <p>I have read that this works, but I can't get it to. I want to pre populate Core Data. I ran my project so it would create the sqlite file. I copied that to my desktop and then prepopulated it using the command line, sqlite3. I ran queries to make sure it was populated correctly. So now I re-add it to my project. No matter what I do, though, it won't fetch the data.</p>
  
  <p>I got it to work ONCE. I re-copied the sqlite file from my project's document folder after running it in the simulator. I then populated this new sqlite file. I put it back in my project and I got the contents to display.</p>
  
  <p>I think the problem is the Z_METADATA table. This table has a Z_UUID attribute. I think the only time it worked was when the simulator's UUID and the sqlite's Z_UUID attribute were the same.</p>
  
  <p>I went into ~/Library/Developer/Xcode/DerivedData and deleted the contents of the DerivedData folder. So now my simulator will have a different UUID when I run it. I did this and now the contents of the sqlite file will not display. This is why I think the Z_METADATA table is the problem. The Z_METADATA's UUID and my simulator's UUID are not the same so for some reason it can't use it?</p>
  
  <p>All the articles about pre populating Core Data this way I found are old, around 2009, so I don't think this was a problem then. So can I use this method of copying the sqlite file, using the command line to pre populate it, then re-adding it to the project? Does anyone have a current way to prepopulate Core Data?</p>
  
  <p>So the error is that my <code>NSFetchedResultsController</code> is returning a count of 0 objects. I got it to return all the data the one time I mentioned above.</p>