Completely Shut Down Core Data Stack

I need to completely shut down the Core Data Stack in my app and then restart it.


Steps I am currnelty taking:


1) Save any pending changes on the view context

2) call a reset on the view contrext

3) obtain a list of stores from persistentContainer.persistentStoreCoordinator.persistentStores

4) for each store call storeCoordinator.remove(store)

5) set my view context & persistentContainer to nil



Are there any other steps that I need to take to complete shut down the Core Data stack before reinializing it?

Replies

The reason for my question. If I follow the process I just described, everything works fine except for subscribing to NSManagedObjectContextObjectsDidChange. I am doing peer-to-peer replication and I can't get the updated version of the entities being changed. If I reboot the app instead of just trying to shut down the Core Data Stack, it all works fine.


There appears to be one more step missing to make the Core Data Stack completely shut down ie in the same state that everything was before the the Stack was initialized.