Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Chris Holloway
Chris Holloway
2,427 Points

Is it possible to Pre-populate a Core Data model?

I am working on a aviation app. One of the functions requires the device to locate and find the closest airport.

I'd like to preload my airport database into core data, is there a legit way to do this? I've done some looking and what I've found so far appears to be kludgy.

2 Answers

What I have done in the past is essentially bundle a populated sqlite database into the project resources and copy it the the app's document directory on first launch. This tutorial is a little dated but it still works:


Chris Holloway
Chris Holloway
2,427 Points

Nice! So, this method is feasible for production code as well as development?

I've used it on the app store and the performance impact is almost negligible. It doesn't require any file parsing or database access, just copying data on flash memory.