|
After completing Day 61 on my own and looking at Pauls answer I noticed that the a number of Friends go missing after Core Data is introduced. Has anyone else noticed this? Is there a reason why this happens? Examples from Pauls solution: Allie Mendoza only has Calderon Blackwell, should have 6 friends Brooks Spence only has Henry Charles, should have 8 friends Barnett Heath has no friends, should have 2 friends I believe it must has somthing to do with the merge policy as if I remove moc.save() and go back and forth on the NavigationLinks my code shows different friends, and different quantity of friends, each time. |
|
Not sure where your problem could be, as you provide no code. I do not have the problem. Maybe it is in your code that fills the database? My
The CachedUserView:
My
My data model has one-to-many relations from Hope this helps, Jeroen. |
|
@Jeroen537 thank you very much for your reply. My code is very similar to yours, so I cannot see why mine doesn't want to show all friends I did try altering my code to be more like yours, but no different. The only thing I could do was
as my User didn't conform to Equatable and adding it didn't compile, but now I think that is because I didn't add comparrison code. I have added my code in case you can find where I have gone wrong. ContentView
UserView
DataController
|
|
I was also facing the same issue. The issue was with the one to many relationships. While you probally set the relationship to be one-to-many for the CachedUsers you also had to set the Cached friends to have a one-to-many relationship. The answer is also found in this post https://www.hackingwithswift.com/forums/100-days-of-swiftui/day-61-missing-data-while-working-with-core-data/13612 |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.
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.