I'm not quite sure I understand what you try to accomplish, but ...
It seems that what you are doing is not "renaming" but "re-assigning" a contract to a new user.
Meaning, you are creating "Person C" and assign "Contact A" to it.
I'm not sure what is the behaviour you try to implement.
If you like a Person
with no Contract
s simply to not appear in your view controller,
but still exist in your store, you will need the following:
In your "person view controller" use this predicate for the fetched results controller:
NSPredicate* p = [NSPredicate predicateWithFormat:@"contracts.@count != 0"];
if you like to delete a Person
with no Contract
s you will need to add custom logic.
This might look something like:
//This goes in your `Person` entity implementation file
- (BOOL) validateForUpdate:(NSError *__autoreleasing *)error
{
if (![self hasFaultForRelationshipNamed:@"contracts"] && [self.contracts count] == 0) {
[self.managedObjectContext deleteObject:self];
}
return [super validateForUpdate:error];
}