In my application, I observe the properties of a managed object. A change may lead to adjustments in some of its other properties, so the managed object itself receives a message of a changed property. These changes happen through bindings that are set up in the Interface Builder.
I have the following method in the implementation of the managed object:
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if ( !processingChange )
{
processingChange = YES;
*** DO STUFF TO THIS MANAGED OBJECT'S PROPERTIES ***
[self.managedObjectContext processPendingChanges];
processingChange = NO;
return;
}
}
The processingChange
boolean is there to avoid an endless "notification loop", but it is not working as I expect (plus it looks like a real dirty hack).
There must be another way to do this. Any suggestions?