Hi,
I'm working on an app where I'm using Core Data to store some information on persistent storage. I'm having issues understanding and deciding how to deal with read/write operations.
At the moment, I have a QuoteGroupStorageManager class that wraps most of the operations in easy to use functions. You can see it below.
You can see that I'm fetching on the main context, and editing/deleting/inserting (apart from the addQuoteToGroup which I do on the mainContext because I use relationships, and the quoteGroup belongs on the mainContext - otherwise I get an error with illegal... object belongs to a diff context).
My question is, am I doing things right, in terms of performance? I'm using SwiftUI for the UI and when I delete a QuoteGroup for example, the UI is freezing for a while, until I make a new deletion. I'm wondering if it's because of the mixture of backgroundContext and mainContext. Which one should I use?
Thanks!
I'm working on an app where I'm using Core Data to store some information on persistent storage. I'm having issues understanding and deciding how to deal with read/write operations.
At the moment, I have a QuoteGroupStorageManager class that wraps most of the operations in easy to use functions. You can see it below.
You can see that I'm fetching on the main context, and editing/deleting/inserting (apart from the addQuoteToGroup which I do on the mainContext because I use relationships, and the quoteGroup belongs on the mainContext - otherwise I get an error with illegal... object belongs to a diff context).
My question is, am I doing things right, in terms of performance? I'm using SwiftUI for the UI and when I delete a QuoteGroup for example, the UI is freezing for a while, until I make a new deletion. I'm wondering if it's because of the mixture of backgroundContext and mainContext. Which one should I use?
Thanks!