Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Core Data Child Context

I have 2 questions regarding context creation.

When i access main context via singleton:

let appDelegate = UIApplication.shared.delegate as! AppDelegate
let managedContext = appDelegate.managedObjectContext

Is that the SAME context everytime?

And if i then create a child context like this:

let bgContext = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)

With Parent as the about main context, is that the SAME child context or is it generating a completely new child context.

Thanks!

like image 334
Dsk Avatar asked Apr 18 '26 07:04

Dsk


1 Answers

Yeah, as long as it's a stored property, appDelegate.managedObjectContext is the same object every time.

And to your second question, that's a new child context. You can go from here to read more from Apple's documentation.

like image 193
Oscar Apeland Avatar answered Apr 20 '26 03:04

Oscar Apeland



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!