Before doing my latest project, I poured over the "Model Object Implementation Guide" and the NSManagedObject Class Reference. Both documents state categorically that NSManagedObjects do NOT automatically provide KVO notification unless one overrides +(BOOL)automaticallyNotifiesObserversForKey.

So, I dutifully sent willChangeValueForKey and didChangeValueForKey in the setter method for my unmodeled property - an action that in the end caused a difficult to find KVO related bug. After commenting out these two statements, everything started working!

Well, it thus became obviously that KVO was already enabled for this non-modeled property, so I added a log message to test this hypothesis:

NSLog(@"AUTO=%d", [Template automaticallyNotifiesObserversForKey:@"topDSimObject"]);

Sure enough it prints out AUTO=1!  Yikes! How did that happen?


Here is my interface:

@interface Template : NSManagedObject
{
   DSimObject  *topDSimObject;
}
@property (nonatomic, retain) NSString * name;
...

// tried both as a property and not, no change
//@property (nonatomic, retain) DSimObject* topDSimObject;

- (void)setTopDSimObject:(DSimObject *)object;
- (DSimObject *)topDSimObject;

@end


So, what am I missing?

David




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to