So, I'm pretty new to Core Data and KVO, but I have a subclass of NSManagedObject that successfully respects its own relationships with many. The problem is that with the observed changes, I want to iterate through only a set of objects that have been added or deleted. Is there a way to access these elements directly? Or should I do something relatively inefficient, like this:
NSSet* newSet = (NSSet*)[change objectForKey:NSKeyValueChangeNewKey]; NSSet* oldSet = (NSSet*)[change objectForKey:NSKeyValueChangeOldKey]; NSMutableSet* changedValues = [[NSMutableSet alloc] initWithSet:newSet]; [changedValues minusSet:oldSet];
I feel that you should be able to avoid this, because in these posts ...
[self willChangeValueForKey:forSetMutation:usingObjects:]; [self didChangeValueForKey:forSetMutation:usingObjects:];
you pass it the added / deleted objects! Perhaps it is useful to know what happens to these objects?
source share