shuiyouren / sqlitepersistentobjects

Automatically exported from code.google.com/p/sqlitepersistentobjects
0 stars 0 forks source link

-observeValueForKeyPath:... should call super #62

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What is the expected output? What do you see instead?
SQLitePersistentObject.m -observeValueForKeyPath:ofObject:change:context: 
should call super. It 
does not.

What version of the product are you using? On what operating system?
iPhone 2.2 - r132

Please provide any additional information below.
There is no guarantee that NSObject is not observing any of its own properties, 
or will begin doing so 
in future.

When adding, one should provide a static void* context pointer and use the 
address of this pointer as 
the context parameter. In -observeValue..... the context pointers should be 
compared and super 
called if the context pointer is not ours.

E.G

static void *SQLitePersistentObjectObservationContext = (void 
*)@"SQLitePersistentObjectObservationContext";

/*....*/

[self addObserver:self forKeyPath:property options:0 context:& 
SQLitePersistentObjectObservationContext];

/*...*/

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object 
change:(NSDictionary *)change 
context:(void *)context
{
      if (context == &SQLitePersistentObjectObservationContext
       dirty = YES;
      else
           [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}

Original issue reported on code.google.com by j.p.dann on 26 Mar 2009 at 6:41