Reputation: 8947
I'm here to ask you how should I use threaded core data. I'm going to do it as
make ManageObjectContext
for every controller class which is calling Database methods. This I 'll get by passing controller name as parameter in methods. And in my Database class. I've a shared ManageObjectContext
and a dictionary in which I'll set ManageObjectContext
for controller to retrieve or to set. Can you guys tell me if there is any drawback for it. One that I've noticed is all ManageObjectContexts
will be in memory for all times. If someone can provide any other approach plz sugest. Thanks.
Upvotes: 0
Views: 154
Reputation: 162722
Core Data threading is hard. Fortunately, there is an entire guide available that documents how to manage concurrency in Core Data.
Whether or not memory usage is problematic is only something that can be answered by measuring memory usage, typically with the Allocations Instrument. A managed object context, in and of itself, is fairly cheap. The real question to answer is how much of the managed objects themselves (really, the data contained within) are copied between those contexts. Instruments also has Core Data specific instrumentation that can be very useful.
Upvotes: 2