So I'm fairly new to Core Data and KVO, but I have an NSManagedObject subclass that is successfully observing its own to-many relationship. The problem is, on observed changes, I want to iterate through only the set of objects that were added or removed. Is there some way to access these items directly? Or must I do something relatively inefficient like:
NSSet* newSet = (NSSet*)[change objectForKey:NSKeyValueChangeNewKey];
NSSet* oldSet = (NSSet*)[change objectForKey:NSKeyValueChangeOldKey];
NSMutableSet* changedValues = [[NSMutableSet alloc] initWithSet:newSet];
[changedValues minusSet:oldSet];
I feel like you should be able to avoid this because in these messages...
[self willChangeValueForKey:forSetMutation:usingObjects:];
[self didChangeValueForKey:forSetMutation:usingObjects:];
you're handing it the added/removed objects! Perhaps knowledge of what happens to these objects would be helpful?
didChangeValueForKey:withSetMutation:usingObjects:
Not exactly intuitive, is it? – Laresa