I am working on the project similar to SwiftUI tutorial . I have a "favourites" button done, but every time app restarts, list of marked items is gone. I understand Core Data is the way to go, but as each item (struct) has a lot of information attached (pictures, text etc.) and "favourite" is just one Bool. I am not sure how to use Core Data and not to overload it. Do I need to use Core Data to save every item with all information(pictures, text etc.) or just bool and some reference to e.g. "id"?
Tell if you have any problem in doing so.
A simple way to do it is to create a dictionary, with ID as key and a Bool value for favorite.
Then save as UserDefaults.
See a detailed example here:
https ://cocoacasts. com/ud-4-how-to-store-a-dictionary-in-user-defaults-in-swift
Don't forget to close the thread once solved. Good continuation.
A simple way to do it is to create a dictionary, with ID as key and a Bool value for favorite.
Then save as UserDefaults.
See a detailed example here:
https ://cocoacasts. com/ud-4-how-to-store-a-dictionary-in-user-defaults-in-swift
Don't forget to close the thread once solved. Good continuation.