Okay - I might be losing my mind and I hope I am, because the alternative seems worse right now. I upgraded to Xcode 9.4 and all of a sudden my Core Data app started acting crazy. I think I've found something, but it makes no sense to me.
All of a sudden, in prepareForDeletion, it seems that the object being deleted has had it relationships already deleted! When I go to log the objects that are in relationship to the object, there are no objects!
For example, if my object being deleted is Department, and I want to perform an action on all the Department's Employees before deleting the Department.
- (void)prepareForDeletion {
NSLog(@"prepareForDeletion");
NSMutableArray *employees = [[NSMutableArray alloc] initWithArray:[self.employees allObjects]];
NSLog(@"employees:%@",employees);
for (Employee *employee in employees) {
NSLog(@"employee.name:%@",employee.name);
}
}
The two NSLogs show that there are no employees in the Department by the time we are in the prepareForDeletion method. However, when I run the same code right before I delete the object, all of the Department's employees are listed!
This seems very, very wrong. It basically kills my app right now, since I use this so much. So someone please tell me - am I going crazy? Did I miss something here? Or is this actually an issue with Xcode 9.4?
Am I right in assuming that object relationships should NOT be deleted already, at this point?