Hello,
First post here, so go easy! :)
I have made it up to Day 61, and CoreData is something I am really keen to learn thoroughly. I have previously developed a prototype of an app using CoreData using UIKit, but I am keen to learn SwiftUI now.
I've got the Friend app working fine with structs for the data and have converted the main data into CoreData now. So far the app decodes the JSON, imports it into CoreData, and displays the information in the app using the CoreData Model. So far so good.
I'm at the point where I now want to click on a User, and it go through to the User detail screen, to show both the information on the User and the list of friends etc.
However, I believe the slight change that takes place during the conversion to CoreData is around pushing the data around the App.
I have fetched the data in the ContentView and it contains a FetchRequest variable of all the users. Now when I click on a user, I am struggling to push the data through to the DetailView. Am I even supposed to push the data, or should I be running a new fetch request inside the detail view based on the user selected?
Previously I pushed the user through to the detail view, and in the init() of the detail view used the ID's of the friends to create a new array of the users that were the friends of the User. However when I try and push the fetch request through now, I get the following error :
Cannot convert value of type 'FetchedResults<UserCD>' to expected argument type '[UserCD]
So do I run a new fetch request in the detail view? Or am I missing something? It doesn't feel like the moving of data around in an app using CoreData is really covered in the tutorials up to the challenge so I am struggling a little.....
I guess what I'd like help on is the core (pardon the pun) concept of using CoreData in an app with multiple views.
Thanks in advance,
Chris.