I am making a NSFetchRequest for a NSManaged Object on my initial screen. I sometimes have a crash in a scenario when I :
- switch to another view controller within my tab bar controller
- make another fetch request with the same managed object type
- delete a common managed objects which also appears in my initial VC's fetchrequest. The VC contains a table view.
- save the managed context
- toggle to the first VC, and reload the data
I am not using NSFetchResutltsController to manage these returned objects. The crash happens when my tableview reloads. I do make another request, and expected the deleted objects not be returned, but it does. When my cells are trying to read a property of the deleted object, it reads uninitialized
and crashes. This happens about 1 out of 5 times when toggling between the 2 VCs. I am using performAndWait
in all of my CoreData functions.
Is there a way to decouple the the relationship of the Managed Objects between the two screens? If not, how can I get my fetch request in the first VC, not return the objects that were deleted in the second VC, keeping them in sync?