|
I am trying to load some data into core data and keep getting the following error: [error] error: No NSEntityDescriptions in any model claim the NSManagedObject subclass 'HymnTracker.HymnsPlayed' so +entity is confused. Have you loaded your NSManagedObjectModel yet ? I have also set the module to: Current Product Module and that didnt work. Not sure what Im doing wrong. Any help would be greatly appreciated. Thank you in advance Here is the code im using
|
|
hi, i'm not sure what the value of if you are just trying to load data from .json into Core Data (presumably just once), and if you have some sort of MainView in your app, a quick and cheap way to load of hymns directly from your .json file into Core Data in its .onAppear() modifier, using a function in the MainView something like this:
you can build
if you need examples, i'll suggest taking a look at my ShoppingList project where i load data at startup of an app from .json files directly into Core Data if they have not been previously loaded. finally, about your ListOfHymns class ... if all this does is track what's in Core Data, you'll have to load it from Core Data at startup (so, in the hope that helps, DMG |
|
@delawaremathguy thanks for the reply. The fixed data type is a struct that i use so i can loop over listOfHymns and put them into a list to display to the user. I will try to move the coredata stuff to my AppView which is a TabView. |
SPONSORED Still waiting on your CI build? Speed it up ~3x with Blaze - change one line, pay less, keep your existing GitHub workflows. First 25 HWS readers to use code HACKING at checkout get 50% off the first year. Try it now for free! Sponsor Hacking with Swift and reach the world's largest Swift community! |
|
@delawaremathguy. I don't understand this line that you suggested
where is the coreDataStoreIsEmpty function coming from? You just said that I could build that in my class and then you put a count function in the extension. Could you explain that to me, so I can understand it? Thanks |
|
hi, this is all i meant -- sorry for the confusion.
hope that helps, DMG |
|
@delawaremathguy Thank you for getting back to me. So am I correct in assuming that I would just create an extension of the HymnsPlayed class and add the coreDataStoreIsEmpty function to that extension? If so then I assume I wouldn't need the count function you told me about earlier or is there some need for that? Sorry for all the questions, Im just trying to understand how it all works. Thanks Mark |
|
hi, add the i think that should do it, DMG |
|
|
|
Hi DMG @delawaremathguy, I have my app working with coredata loading from the start. Thank you for helping me with that. I have another question! I want to have some sort of notification/alert system that tells the user that a hymn has been added/deleted/updated in the database. How would I go about this. I have been looking at your ShoppingList Project but Im not really sure what Im looking for. So Im just spinning in circles. Could you give me some direction in how to accomplish this. Thanks Mark |
|
hi Mark, UPDATED ON SECOND READ ...
my suggestion is to start a new thread with more information about what you're trying to accomplish. how does you app really work? how do you use the data that's now in Core Data? i hope i can help in the future, DMG |
|
Hi DMG, You're right I did get accomplished what I was asking in this thread. I appreciate your help with that. I will start a new thread about the other question I have. Thanks. Mark |
SPONSORED Still waiting on your CI build? Speed it up ~3x with Blaze - change one line, pay less, keep your existing GitHub workflows. First 25 HWS readers to use code HACKING at checkout get 50% off the first year. Try it now for free!
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.