WWDC22 SALE: Save 50% on all my Swift books and bundles! >>

Using CoreData for a reference guide, and if so, how to preload the data?

Forums > Swift

Hi everyone, I'm looking to build an app that basically will take an existing game reference guide and make it searchable in an app. The reference guide is a very straightforward list of words and their definitions. From the user's point of view it will be read only. Is this a good candidate for a CoreData database? If it is, what's the best way to preload the data into the database the first time the user opens the app?

The data itself is in a text file which will be in the app package (it won't need to be changed dynamically) and I'll be using delimiters to split the text into the name and definition columns.

Thanks, Alistair


I don't have an answer, but this is something I've been curious about for a while and would like to be notified of any responses. :D


I am fairly new and learning so please take that into account with my answer...

Is there a reason you want to use Core Data? From your explanation, and my limited knowledge, it seems like the juice isn't worth the squeeze.

To me, you should just leave this in a dictionary as part of your app instead of trying to push it into Core Data. Then you should be able to use .contains or another method if the user wants to search.

I also watched Paul's HWS Live yesterday and he showed off a Searchable feature that adds a search bar in a list. I haven't played with this yet but it may be something you wish to use. For example, if everything is in a String, String dictionary, you could list the word and definition in a list and search thru it.

I hope this makes sense. If I missed the boat, I apologize. So many have helped me on this forum and I am just trying to use my limited knowledge to give back some.


I was wondering if I was perhaps overdoing it by using CoreData. As you said, it may be better to go with a more straightforward approach.

Appreciate the input!


For what it's worth, I'm fairly certain this (prepopulated coredata) is the approach several apps take with similar featuresets (reference material).

Even if coredata is overkill, it's probably a great learning opportunity.


Hacking with Swift is sponsored by Emerge

SPONSORED Why are Swift reference types bad for app startup time, and what’s the performance cost of protocol conformances? That’s just a couple of the topics you can learn about on the Emerge blog — written by the app performance experts behind Emerge’s advanced app optimization and monitoring tools, based on their experience of working at companies like Apple, Airbnb, Snap, and Spotify.

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.