Open missphyrgames opened 12 months ago
I think you have two requirements here so I'll split my comments for each:
You can actually create the SQLite file separately and bundle that into your app. The good thing is that you can use the exact models you use on iOS (etc.) and generate the SQLite files from a macOS playground or command line app for example.
You'd then have to copy that file into the app sandbox on the first launch (or overwrite as needed). CoreStore currently has no "readonly" mechanism at the store level, so you'd have to do this file management yourself.
CoreStore also has no specific API for this, but you can easily declare multiple DataStacks
and manually fetch the static data from one of them using a shared foreign key.
Thank you for your reply!
For the first point, I actually did try that out and it worked but I had to use fetched properties if I wanted anything similar to a relationship (but this had it's downfalls and limitations). Unless by copying it over we can setup relationships? I'm still slightly confused on this point. How would we setup relationships?
For the second point, I couldn't find any examples of manually fetching the data using a shared foreign key. What do you mean by this?
Sorry, I'm still relatively new to iOS development but really appreciate the help!
Sorry for the radio silence. By foreign key, it means some sort of ID that identifies a related object. So you store it as a field and then later use the ID to fetch the actual object. Basically similar to fetched properties.
Hey! I'm trying to create a sample app with the library and the aim is to have a read only store that's supplied with the app bundle and a read-write store in their documents (or the default location where this library/core data creates them). For example, suppose it's a Contacts app where there's a contact entity and also a favourites entity. The user would be supplied with default contacts that they can only read from. They can favourite these contacts which would be visible in another page.
A way to do this with core data was by using fetched properties, however, you can't create relationships between the stores unfortunately so it didn't work well for my situation (as I also wanted to sort the favourites based on the name of the contact). The reason I wanted to have a read only store was so I could easily update the data in an app update without re-seeding core data.
Is there a way I could accomplish it with this library? Or do you have any suggestions on how to implement this? Thank you :)