If I need to programmatically empty a NSSet automatically created by Core Data (multiple relationships), what should I do ? Something like this ?
[self willChangeValueForKey:@"MyRelationship"];
[[self MyRelationship] release];
[self MyRelationship] = [NSSet alloc] init];
[self didChangeValueForKey:@"MyRelationship"];
Not sure it is correct at all…
thanks
For some reason, I can never get the “cascade” delete rule to work, so when I want the objects deleted as well I have to iterate over the set and call
[self.managedObjectContext deleteObject:obj]or else I’ll get validation errors, if the relationship is defined as required.