Given a Core data app. I'd like to prevent a deletion if a relationship is not empty.
The best method seems to be with validateForDelete
. Yet, when quering the size of the relationship it returns 0.
The following sets all return a non-nil object but a count of 0.
- (BOOL)validateForDelete:(NSError **)error {
NSSet *emp0 = [self employees];
NSSet *emp1 = [self valueForKey:@"employees"];
NSMutableSet *emp2 = [self mutableSetValueForKey:@"employees"];
...
if ([emp0 count] <= 0) return YES:
else return NO;
}
The set is definately not empty. Perhaps the NSArrayControllers are not properly configured..!