In core data do all relation objects get deleted too when deleting an entity's objects there is an another entity Details which has one to many relationship. Do I need to delete its objects or the following code takes care of it? my code so far:
NSFetchRequest * allClients = [[NSFetchRequest alloc] init];
[allClients setEntity:[NSEntityDescription entityForName:@"Client" inManagedObjectContext:[NSManagedObjectContext defaultContext]]];
[allClients setIncludesPropertyValues:NO]; //only fetch the managedObjectID
NSError * error = nil;
NSArray * clients = [[NSManagedObjectContext defaultContext] executeFetchRequest:allClients error:&error];
//error handling goes here
for (NSManagedObject * client in clients) {
[[NSManagedObjectContext defaultContext] deleteObject:client];
}
NSError *saveError = nil;
[[NSManagedObjectContext defaultContext] save:&saveError];
//more error handling here
That depends on what settings you have configured. For each relationship you can set it to:
You specify this for each relationship in the model (and both ends of each relationship).