Making an App for Fun - Question about adding future data without compromising existing user data

I’m making a Pokedex app just to learn for myself. It uses Core Data to make 151 Pokemon objects. The user can favorite some Pokemon and this is saved. When a user fires up the app I can check if it is the first time they are running the app and preload/create 151 Pokemon objects for the app.

My question is about future iterations of the app. There are more than 151 Pokemon and if I add, say, an additional 100 in a future release, how do I check if those 100 exist or they need to be added?
Checking the number of Pokemon that exist in core data would work, but it would only apply only in this Pokemon scenario (My goal is to learn for general purposes). Doesn’t sound like the best-practice solution.
I’m thinking programmers generally check/match if users have the objects preloaded, and add whatever is missing. I don’t know how to make such comparisons or what the general best-practices are when dealing with such data.

Any suggestions/tutorials/advice?

Well I would definitely go with the cloud on this. In other words, you are wondering what would happen if a user starts with a blank slate of 0 favorited pokemons and 150 possible pokemons he can favorite.

After sometime he would favorite some pokemon, lets say 5, leaving 145 unfavorited pokemons in his core data locally. If later you were to update the app with 200 pokemon, then you would have to basically copy coredata-localdata, paste-into-new-db, erase-old-coredata-db. This is a migration and depending on your structure it takes a little to a lot of work. You can find an excellent example here:

https://www.raywenderlich.com/114084/core-data-migrations-tutorial-lightweight-migrations

If you want to avoid all that, you can simply make the app store and fetch all available-pokemon data as well as user-favorited-pokemon data from the web where you would store user accounts. This has the great advantage of letting you modify your cloud db in many ways at any time without affecting the user side, but the disadvantage of making the app slower to load by making it fetch from the web. Then again you can also control when the app fetches so that shouldn’t be an issue. We have a tutorial on that as well:

https://www.raywenderlich.com/109706/firebase-tutorial-getting-started

1 Like